0
嗨,我是使用下面的代碼來發送HTTPS GET請求,另一個API蛋糕php http GET與承載密鑰?
$access_token = $this->Session->read("AUTH_BEARER");
$url = GET_DOCUMENT_BY_ID_URL.'202';
$curl=curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 0);
curl_setopt($curl, CURLOPT_HTTPGET, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Authorization: Bearer ".$access_token));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);// comment this line in live servers
$response_json=curl_exec($curl);
$error= curl_errno($curl);
$error_message= curl_error($curl);
echo "error:".$error;
echo "<br>";
echo "Error message:".$error_message;
echo "<br>";
curl_close($curl);
$response_array = json_decode($response_json,true);
echo $response_json;
但我沒有收到來自服務器的響應。我收到不記名令牌後立即撥打此電話,所以我希望在令牌過期之前撥打了該電話。我在這裏做錯了什麼?有人可以幫我解決這個問題嗎?在此先感謝您。注意:我使用的是https://不是http://
這裏如何設置持票人令牌數組(「Authorization:Bearer」。$ access_token) –
檢查我的答案我修改 –