iT邦幫忙

0

php中使用raw格式發送post請求

在php中使用raw格式發送post請求,但一直無法正確取得rest api的結果,程式碼如下,請參考,謝謝

<?php
    $url="rest api url";
    $postData = $inputJson_encode;
    $result=PostFunction($url,$postData);
    echo $result."<br>";

    function PostFunction($url,$postData){
        $ch = curl_init();
        curl_setopt( $ch, CURLOPT_URL, $url);
        curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt( $ch, CURLOPT_POST, 1);
        curl_setopt( $ch, CURLOPT_POSTFIELDS, $postData);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'X-AjaxPro-Method:ShowList',
            'Content-Type: application/json; charset=utf-8',
            'Content-Length: ' . strlen($postData))
        );
        curl_setopt($ch, CURLOPT_TIMEOUT_MS, 30000);
        $result = curl_exec($ch);
        $errorNo = curl_errno($ch);
        return $result;
    }
?>
說真的,這個問題你需要先問你的發送端才對。
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答