doutan8775 2013-12-27 10:51
浏览 67
已采纳

REST-Client:302尝试传递XML-String时找到

I want to implement a REST-Client which handles form input data and sends it to an REST Backend.

$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);

But it seems, that there's something wrong, maybe with the webserver config. It says:

    302 Found
The document has moved here.

But the var_dump of the xml string is correct. What's my error in reasoning?

  • 写回答

1条回答 默认 最新

  • doutui6241 2013-12-27 10:53
    关注

    You are facing a redirect.. Add this cURL param

    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题