PHP Facebook FQL: Making queries in the new SDK

送分小仙女□ 提交于 2019-12-22 00:18:33

问题


New to PHP and Graph API.

It seems that in the old API you could create a facebook object and pass in a standard query (select blah in blank where x = y ...) but now I don't see how to do that. All of the examples in the facebook documentation have you using a get_file_contents for graph.facebook.com/?fql etc. I've been trying to use that but it seems inefficient for complex queries.

Help? I'm kinda confused and don't understand some of the facebook documentation.

Thanks.


回答1:


Using the PHP SDK you can run fql queries by :

$facebook = new Facebook(array(
       'appId'  => 'YOUR_API_KEY',
       'secret' => 'YOUR_API_SECRET',
       'cookie' => true,
));

 $fql = "Your query";

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

 print_r($response);

I’ve also seen it done this way as well:

$param  =   array(
      'method'    => 'fql.query',
      'access_token' => $cookie['access_token'],
      'query'     => $fql,
      'callback'  => ''
);
$response   =   $facebook->api($param);
print_r($response);

Hope this helps :)




回答2:


Try this, it's pretty elegant:

$param  =   array(
    'method'    => 'fql.query',
    'access_token' => $cookie['access_token'],
    'query'     => $fql,
    'callback'  => ''
);
$response   =   $facebook->api($param);
print_r($response);


来源:https://stackoverflow.com/questions/9060102/php-facebook-fql-making-queries-in-the-new-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!