使用PHP获取FQL数据

Den*_*one 2 php facebook

*UPDATE 正在返回数据但未输出到浏览器.当我在下面的答案中使用urlencode建议后,当我查看源代码时,它就在那里.**

用这个把头发拉出来.

基于以下链接:

facebook FQL概述

FQL视频表信息

此代码应该可以提取我需要的表数据:

ini_set("display_errors","2");
ERROR_REPORTING(E_ALL);

$contents = file_get_contents('https://api.facebook.com/method/fql.query?query=SELECT vid, owner, title, description, thumbnail_link, embed_html, updated_time, created_time FROM video WHERE owner= *******myID****');

echo $contents;
Run Code Online (Sandbox Code Playgroud)

但是我收到以下错误:

Warning: file_get_contents(https://api.facebook.com/method/fql.query?query=SELECT  vid, owner, title, description, thumbnail_link, embed_html, updated_time, created_time FROM video WHERE owner= ******myID*****) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in /vservers/mywebsite/htdocs/test.php on line 5
Run Code Online (Sandbox Code Playgroud)

谁能看到我做错了什么?

Jam*_*s C 5

尝试将主线更改为:

$enc = urlencode('SELECT vid, owner, title, description, thumbnail_link, embed_html, updated_time, created_time FROM video WHERE owner= *******myID****');
$contents = file_get_contents("https://api.facebook.com/method/fql.query?query=$enc");
Run Code Online (Sandbox Code Playgroud)