我的FQL请求不知何故在PHP中工作。在Graph API Exporer中,查询工作正常。这是我的主要代码:
$params = array(
'method' => 'fql.query',
'query' => "SELECT friend_count FROM user WHERE uid = me()",
);
// graph api request for user data
$request = new FacebookRequest( $session, 'GET', '/me', $params );
$response = $request->execute();
// get response
$graphObject = $response->getGraphObject()->asArray();
// print profile data
echo '<pre>' . print_r( $graphObject, 1 ) . '</pre>';
这是Facebooks错误:
致命错误:未捕获的异常&#39; Facebook \ FacebookAuthorizationException&#39;有消息&#39;不支持的方法,fql.query&#39;在/vendor/facebook/php-sdk-v4/src/Facebook/FacebookRequestException.php:104堆栈追踪:#0 /vendor/facebook/php-sdk-v4/src/Facebook/FacebookRequest.php(268):Facebook FacebookRequestException :: create(&#39; {&#34; error&#34;:{&#34; mess ...&#39;,Object(stdClass),400)#1 / www / htdocs / app / facebook .php(97):在第104行的/vendor/facebook/php-sdk-v4/src/Facebook/FacebookRequestException.php中抛出的Facebook \ FacebookRequest-&gt; execute()#2 {main} (路径名称已更改)
答案 0 :(得分:1)
尝试替换
$request = new FacebookRequest( $session, 'GET', '/me', $params );
与
$request = new FacebookRequest( $session, 'GET', '/fql?q=SELECT%20friend_count%20FROM%20user%20WHERE%20uid%20%3D%20me()');
查看https://developers.facebook.com/docs/technical-guides/fql/#read