Shell:
Код: Выделить всё
curl --request POST --data -k '{"district":"sandbox"}' --location https://dev.myurl.ca/api/update.php?key=abc
PHP:
Код: Выделить всё
$payload = [
'district' => 'sandbox',
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://dev.myurl.ca/api/update.php?key=abc");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
curl_close($ch);
Код: Выделить всё
{"errormessage":"missing parameter- district","status":"fail"}
Спасибо.
Подробнее здесь: https://stackoverflow.com/questions/792 ... equest-php
Мобильная версия