我遇到了使用自定義標題的PHP curl命令的問題。任何人都可以看到這裏發生了什麼?關於PHP的錯誤請求Curl
$url = "https://api.sitescout.com/oauth/token";
$ch = curl_init();
$headers = array(
"POST https://api.sitescout.com/oauth/token HTTP/1.1",
"Host: api.sitescout.com",
"Authorization: Basic bGFtcGhvdXNlLWFwaTp2RmhsSmlJMm5BT****",
"Content-Type: application/x-www-form-urlencoded",
"Accept: application/json",
"Content-Length: 41"
);
$post_fields = array(
'grant_type' => 'client_credentials'
);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
print_r($output);
curl_close($ch);
//var_dump($output);
這是服務器響應。
HTTP/1.1 400錯誤的請求 服務器:Apache-狼/ 1.1 日期:星期一,2014年2月10日5時13分09秒GMT 連接:關閉
任何幫助將不勝感激!
壞後的數據? – shapeshifter
你是否解決了這個問題,我得到了同樣的問題,讓我知道你是否可以幫助我。 – s4suryapal