文件获取内容请求400图api

时间:2013-04-17 13:55:44

标签: facebook-graph-api request file-get-contents

当我使用file_get_contents(https://graph.facebook.com/xxxxxxxxx?access_token=xxxxxxxxxxxxxxxx)发出请求时,我得到了这个结果。

遇到PHP错误

严重性:警告

消息:file_get_contents(https://graph.facebook.com/xxxxxxxxx?access_token=xxxxxxxxxxxxxxxx):无法打开流:HTTP请求失败! HTTP / 1.0 400错误请求

但是,当我在我的浏览器中复制网址时,它有用,有人知道吗?

提前致谢

1 个答案:

答案 0 :(得分:0)

使用

$ctx = stream_context_create(['http'=>['ignore_errors' => true]]);
$data = file_get_contents($url, 0 , $ctx);

表示http答案代码与200不同。

ps:5.4的数组语法;如果使用< 5.4

,请将[...]更改为数组(...)