我的代碼:的遊離鹼MQL閱讀服務和PHP的file_get_contents
$api_url = "https://www.googleapis.com/freebase/v1-sandbox/mqlread?query=";
$query = $freebase_query."&callback=myfuncname"."&key=".$cfg['fbkey'];
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar\r\n"
)
);
$context = stream_context_create($opts);
$json = file_get_contents($api_url.$query, false, $context, null);
$display = $api_url.$query;
$json_output = json_decode($json);
錯誤: 警告:的file_get_contents(https://www.googleapis.com/freebase/v1-sandbox/mqlread?query= [ {"中間":空,"名稱":空,"主題:中間| = ":[" /米/ 0gn30 "," /米/ 0tc7 "]}] &回調= myfuncname &鍵= [鍵])[功能.file-get-contents]:無法打開流:HTTP請求失敗! HTTP/1.0 [文件名] 400錯誤的請求 上線
如果我直接將URL粘貼到瀏覽器中我得到的返回結果沒有任何問題!所以我認爲它是我打電話給服務的方式?
看到這個線程:http://stackoverflow.com/questions/3535799/file-get-contents-failed-to-open-stream,HTTP: //stackoverflow.com/questions/1975461/file-get-contents-with-https –