我的代码:
$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=[{"mid": null,"name": null,"topics:mid|=":[" /m/0gn30","/m/0tc7"]}]&callback=myfuncname&key=[key]) [function.file-get-contents]:打开流失败:HTTP 请求失败!第59行[文件名]中的 HTTP/1.0 400 错误请求
如果我将 URL 直接粘贴到浏览器中,我会毫无问题地返回结果!所以我假设它是我调用服务的方式?