使用FQL从Facebook中提取视频表数据

时间:2011-04-23 02:49:22

标签: php json facebook facebook-fql

我发现了一些使用FQL从facebook视频表中提取JSON数据的不同页面。

这会被视为Facebook应用吗?

我正在使用PHP 4运行apache服务器。我的查询为:

SELECT vid, owner, title, description, thumbnail_link, embed_html, updated_time, created_time FROM video WHERE owner= ***myID****

Facebook开发人员说"You can execute FQL queries by fetching https://api.facebook.com/method/fql.query?query=QUERY. You can specify a response format as either XML or JSON with the format query parameter."

我应该做一个

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

require 'include/facebook_api.php';

$facebook = new Facebook(array(
  'appId' => '******myID********',
  'secret' => '******MYSECRET**************',
  'cookie' => true,
));



$fql = "SELECT vid, owner, title, description, thumbnail_link, embed_html, updated_time, created_time FROM video WHERE owner= *****FBID*******";

$response = $facebook->api(array(
'method' => 'fql.query',
'query' =>$fql,
));

print_r($response);


?>

包含文件是:https://github.com/facebook/php-sdk/blob/master/src/facebook.php

我收到以下错误:

stdClass Object ( [error_code] => 190 [error_msg] => Invalid OAuth 2.0 Access Token [request_args] => Array ( [0] => stdClass Object ( [key] => method [value] => fql.query ) [1] => stdClass Object ( [key] => query [value] => SELECT vid, owner, title, description, thumbnail_link, embed_html, updated_time, created_time FROM video WHERE owner= ***************** ) [2] => stdClass Object ( [key] => api_key [value] => ***************** ) [3] => stdClass Object ( [key] => format [value] => json-strings ) [4] => stdClass Object ( [key] => access_token [value] => ***************** ) ) ) 

任何信息或坚实的方向都会很棒。

1 个答案:

答案 0 :(得分:0)

以下是最终工作的代码。

header('Content-type: application/xml');
//ini_set("display_errors","2");
//ERROR_REPORTING(E_ALL);

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

echo $contents;