簡體   English   中英

為什么PHP + curl,HTTP POST請求返回null?

[英]why PHP + curl, HTTP POST request returns null?

我很困惑為什么$ 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);

在郵遞員中

在此處輸入圖片說明

請添加以下行以定義請求類型(GET / POST / ..),然后嘗試:

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");

下載cacert.pem文件保存在根目錄中並設置curl選項,然后嘗試

http://curl.haxx.se/ca/cacert.pem

curl_setopt ($h, CURLOPT_CAINFO, base_path()."/cacert.pem");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM