Tim Sadvak Tim Sadvak - 5 months ago 12
PHP Question

cURL Post HTTP dont' work correctly by sending to Django site

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

Answer
$url = 'http://someurl.com';

instead of:

&url = http://someurl.com;

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