我很困惑为什么$ response不会返回任何内容,我是新来的请求帮助,
$post = [
'AreaCode' => '02',
'PhoneNumber' => '33312733',
'InquiryBy' => 'telephone',
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://billing.te.eg/api/Account/Inquiry');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type:application/json',
'Access-Control-Allow-Origin: *',
));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$httpCode = curl_getinfo($ch , CURLINFO_HTTP_CODE);
$response = curl_exec($ch);
if ($response === false) $response = curl_error($ch);
echo stripslashes($response);
curl_close($ch);
在邮差中
答案 0 :(得分:0)
请添加以下行以定义请求类型(GET / POST / ..),然后尝试:
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
答案 1 :(得分:-1)
将cacert.pem文件保存在根目录并设置curl选项并尝试
http://curl.haxx.se/ca/cacert.pem
curl_setopt ($h, CURLOPT_CAINFO, base_path()."/cacert.pem");