我想实现一个REST客户端,它处理表单输入数据并将其发送到REST后端。
$strXml = file_get_contents($_FILES['xmlfile']['tmp_name']);
$service_url = 'api/index.php/pojects';
$curl = curl_init($service_url);
$curl_post_data = array(
"title" => $_POST['title'],
"client" => $_POST['client'],
"comment" => $_POST['comment'],
"project_number" => $_POST['project_number'],
"xml" => $strXml,
);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data);
$curl_response = curl_exec($curl);
curl_close($curl);
var_dump($curl_response);
var_dump($strXml);但是看起来,这是有问题的,可能是在webserver配置。上面写着:
302 Found
The document has moved here.但是xml字符串的var_dump是正确的。我的推理错误是什么?
发布于 2013-12-27 10:53:49
你正面临重定向..。添加此cURL参数
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);https://stackoverflow.com/questions/20799349
复制相似问题