Отправка json с помощью cURL не возвращает результат назад, почему? - PullRequest
0 голосов
/ 24 марта 2019

Я пытаюсь отправить этот POST-запрос, и он не даст никакого результата, Я пытался использовать разные приемы, но он либо выдает ошибку 500, либо просто застрял на пустой странице, тогда как он должен отражать, по крайней мере, что-то вроде этого:

{"errorCode":"APP-0001","message":"Something really bad happened. Please contact your administrator, right now!","fields":{},"operationMessage":"Something really bad happened. Please contact your administrator, right now!"}
<?php


$countryCode = $_POST['countryCode'];
$phoneNumber = $_POST['phoneNumber'];


$data = array("countryCode" => "$countryCode", "phoneNumber" => "$phoneNumber");
$data_string = json_encode($data);

$ch = curl_init('https://consumer-edge-service.careem.com/api/v8/user/partialSignup?device=ACMA');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Authorization: SCBOHw6OOZD1lOJyS2dz',
    'Agent: ACMA',
    'User-Agent: ACMA/8.7.7',
    'Device: ' . $phoneNumber,
    'Provider-Access-Key: 6ba82ffa',
    'Version: 8772',
    'x-careem-position: 29.452370,32.752543,1799.999023,1552014765404',
    'Content-Type: application/json; charset=UTF-8',
    'Content-Length: 46',
    'Host: consumer-edge-service.careem.com',
    'Connection: close',
    'Accept-Encoding: gzip, deflate',
    'X-NewRelic-ID: VQMAWFVVABAHVVBXDwgFVA==')
);

curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);

//execute post
$result = curl_exec($ch);

//close connection
curl_close($ch);

echo $result;

?>

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...