无法获得某些用户喜欢的页面 [英] Cannot get page like for some users

查看:68
本文介绍了无法获得某些用户喜欢的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一个PHP应用程序,只要用户喜欢某个页面,就需要获取该应用程序.

I've developed a PHP app which just need to get if the user has liked a certain page.

我以这种方式登录用户:

I login the user this way:

$this->_facebook = new Facebook(array(
        'appId' => "123",
        'secret' => "346",
    ));
$this->_facebookUser = $this->_facebook->getUser();
$this->_facebook->api('/me');

然后

    $checkIfUserLikePage = $this->_facebook->api(array(
        "method" => "fql.query",
        "query" => "select uid from page_fan where uid=me() and page_id=" . $pageid,
    ));

这通常可以正常工作,但对于某些用户却无效,它会返回一个空数组.我已经在线检查过,我的应用程序可能缺少* user_likes *权限.实际上,我没有此许可.所以我再次发现我应该添加权限,卸载应用程序,然后重试.

This mostly works but for some users does not, it returns an empty array. I've checked online and my app is probably missing the *user_likes* permission. And in fact I didn't have this permission. So again I found I should add the permission, uninstall the app and retry.

所以我:

  1. 登录到developer.facebook.com>应用> myapp >应用详细信息>配置应用中心权限
  2. 在用户和朋友权限"文本区域中添加了"user_likes"
  3. 已保存
  4. 要求测试用户删除 myapp
  5. 要求测试用户访问该应用
  1. logged to developer.facebook.com > apps > myapp > App details > Configure App Center Permissions
  2. added "user_likes" to the User and Friend Permissions text area
  3. saved
  4. asked a test user to remove myapp
  5. asked the test user to access the app

结果,我仍然为用户得到一个空数组. 还有什么问题吗?谢谢

As a result I still get an empty array for the user. What else is wrong? thanks

推荐答案

请不要将应用中心的权限与您传递给范围的权限相混淆.在提示用户输入权限时,您是否在范围内添加了"user_likes"?

Don't mistake the permissions in the app center with those you pass to your scope. When prompting the user for permissions, do you have added "user_likes" to the scope?

例如,使用JS-SDK可以做到这一点:

With the JS-SDK you do it like that for example:

FB.login(function(response) {
    // Do some fancy stuff
}, {scope: 'user_likes'});

还要确保您具有有效的用户访问令牌.您的PHP-SDK提供了一种名为"getAccessToken()"的方法,该方法返回当前的访问令牌.

Also make sure you have a valid user access token. Your PHP-SDK provides a method called "getAccessToken()", which returns the current access token.

您也可以简单地尝试打印getUser()的结果,该结果返回当前用户的userID.如果您为0,则可以确定用户未与您的Facebook应用连接,因此您将无法在FQL查询中使用me().

You can also simply try to print the results of getUser() which returns the userID of the current user. If you get 0, you can be pretty sure that the user is not connected with your facebook app and you'll therefore not be able to use me() in FQL queries.

还用/{user-id}/permissions查询图形API.您将返回一个json对象,其中包含用户授予的所有权限.当然,您需要在您的应用中拥有有效的关联用户才能做到这一点.

Also query the graph API with /{user-id}/permissions. You'll get a json object returned that contains all the permissions the user gave. Of course you need a valid connected user with your app in order to do that.

我希望能给您一些有用的建议.如果没有帮助,请尝试发布更多代码.

I hope I could give you some helpful advice. If nothing helped try posting more code.

快乐编码!

这篇关于无法获得某些用户喜欢的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆