duanfengtuo6012 2016-06-19 22:53
浏览 18
已采纳

cURL发布HTTP不能通过发送到Django网站正常工作[关闭]

everybody

I need to send some form data to another url, when I try to send buy html it works correct, but when I use cURL I receive the following message "MultiValueDictKeyError"

What is from with this curl request?

&url = http://someurl.com;
$user = 'info@some.email';
$scenario_id = 100;
$order_id = rand(0, 999999999999);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_HEADER, false); 
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query('user=$user&scenario_id=$scenario_id&order_id=$order_id'));     
$result = curl_exec($ch);
  • 写回答

1条回答 默认 最新

  • doufutao4428 2016-06-19 23:05
    关注
    $url = 'http://someurl.com';
    

    instead of:

    &url = http://someurl.com;
    

    Also: http_build_query expects an array or object, not a string.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!