Facebook PHP FQL 页面查询停止工作

发布于 2024-12-18 17:25:11 字数 1000 浏览 3 评论 0原文

在过去的一年半里,我一直在使用这段代码,成功地提取用户作为管理员的 Facebook 页面(在被授予权限后),以允许他们选择他们想要发布某些内容的页面。但是,它最近开始返回一个空数组(而不是结果数组) - FQL 或 PHP Rest SDK 停止工作了吗?

require_once('path/to/facebook/php-sdk/src/facebook.php');

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

$session = $facebook->getSession();

$me = null;

// Session based API call.
if ($session) {
    try {
        $uid = $facebook->getUser();
        $me = $facebook->api('/me');
    } catch (FacebookApiException $e) {
        error_log($e);
        die(var_dump($e));
    }
}

if ($me) {
    $pages = $facebook->api(array(
        'method'    =>  'fql.query',
        'query'     =>  'SELECT page_id,name,pic_square,pic_small FROM page WHERE page_id IN ( SELECT page_id FROM page_admin WHERE uid = "'.$me['id'].'" )'
    ));

}

// $pages is an empty array at this point, but used to be an array representing the FQL results for that query.

I was using this code for the past year and a half to successfully pull the facebook pages that a user was an administrator of ( after being granted rights ) to allow them to select which page they wanted to post some content to. However, it recently started returning an empty array ( instead of an array of results ) - has FQL or the PHP Rest SDK stopped working?

require_once('path/to/facebook/php-sdk/src/facebook.php');

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

$session = $facebook->getSession();

$me = null;

// Session based API call.
if ($session) {
    try {
        $uid = $facebook->getUser();
        $me = $facebook->api('/me');
    } catch (FacebookApiException $e) {
        error_log($e);
        die(var_dump($e));
    }
}

if ($me) {
    $pages = $facebook->api(array(
        'method'    =>  'fql.query',
        'query'     =>  'SELECT page_id,name,pic_square,pic_small FROM page WHERE page_id IN ( SELECT page_id FROM page_admin WHERE uid = "'.$me['id'].'" )'
    ));

}

// $pages is an empty array at this point, but used to be an array representing the FQL results for that query.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

手长情犹 2024-12-25 17:25:11

在过去的一年半里,Facebook 改变了我们与他们互动的方式。 SDK 已发生变化,其中使用的方法也略有变化。您应该检查您的代码并确保它与新规范同步。

这里是 PHP SDK 上文档的链接。

此外REST API 已被弃用

in the past year and a half facebook has changed the way we interact with them. The SDK's have changed and the methods used in them have changed slightly too. You should review your code and make sure it is in sync with the new specifications.

here is a link to the documentation on the PHP SDK.

Further more the REST API has been deprecated

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文