* 更新
数据已返回但未输出到浏览器。当我查看源代码时,在下面的答案中使用了urlencode建议之后,一切就在那里了。**
用这个拉我的头发。
基于以下链接:
facebook FQL overview
和FQL Video table info
此代码应该可以提取我需要的表数据:
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;
但是我收到以下错误:
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
谁能看到我做错了吗?
最佳答案
尝试将主线更改为:
$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");
关于php - 使用PHP提取FQL数据,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5767777/