使用cURL发送json不会回显结果,为什么?

时间:2019-03-24 01:22:03

标签: php json curl

我正在尝试发送此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;

?>

0 个答案:

没有答案