Facebook Graph - 用户是否“喜欢”我的页面?

发布于 2024-09-01 10:59:49 字数 306 浏览 5 评论 0原文

我正在尝试升级我的 iPhone 应用程序以使用新的 facebook graph api。 我找不到的一件事是如何查明从我的应用程序连接到 facebook 的当前用户是否是我的 facebook 页面的粉丝 - (即在新范例中 - 用户是否喜欢我的页面)

在 Rest Api 中有一个函数isFan,但不在图表中。

我可以获取用户喜欢的所有项目并搜索其中一个是否是我的页面,但肯定有一种更简单的方法,而不是每次我必须检查他是否是粉丝时都要遍历数千条记录,对吗?

如果有人已经从他们的新文档中弄清楚了如何做到这一点,如果您与我分享,我将非常感激。

I am trying to upgrade my iPhone app to use the new facebook graph api.
One thing I cannot find is how to find out if the current user connected from my app to facebook is a fan of my facebook page - (i.e. in the new paradigm - whether the user likes my page)

In the Rest Api there was a function isFan, but not in the Graph.

I can get all items the user likes and search whether one of them is my page, but certainly there must be an easier way instead of going trough thousands of records each time I must check whether he is a fan, right?

If someone already figured it out how to do that from their new docs, I'll really appreciate if you share it with me.

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

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

发布评论

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

评论(5

或十年 2024-09-08 10:59:49

根据 Facebook 开发文档 旧的 pages.isFan 方法现在在 Graph API 中有一个等效的方法

请注意:我们正在弃用 REST API,并为此方法添加了对 Graph API 的等效支持。您现在可以向 /USER_ID/likes/PAGE_ID 发出 HTTP GET 请求来检查用户是否是粉丝页面。

据此,对 /{USER ID}/likes/{PAGE ID} 的调用将返回必要的信息,前提是您拥有正确的 (user_likes) 权限 或用户的喜好是公开的

According to the Facebook Dev docs the old pages.isFan method has an equivalent in the Graph API now

Please note: We are in the process of deprecating the REST API, and have added equivalent support to the Graph API for this method. You can now issue a HTTP GET request to /USER_ID/likes/PAGE_ID to check if a user is a page of a fan.

As per this, a call to /{USER ID}/likes/{PAGE ID} will return the necessary information provided you have the correct (user_likes) Permission or the user's likes are public

鹤舞 2024-09-08 10:59:49

如果您在 Facebook 调用您的页面时解析 $_POST 变量,则这是最快、最简单的解决方案。 signed_request 包含信息(以及)、用户是否喜欢您的页面,甚至他/她还没有授予对您的应用程序的访问权限。

The quickest and simples solution if you parse the $_POST variable when your page is called by Facebook. The signed_request has the information (as well), the user like your page or not, even s/he hasn't give access to your app (yet).

咿呀咿呀哟 2024-09-08 10:59:49

您正在寻找的是连接表。试试这个:

SELECT target_id, target_type
FROM connection
WHERE source_id = '_THE_USERS_FACEBOOK_ID_'
  AND target_id = '_THE_ID_OF_THE_PAGE_OR_OBJECT_TO_LIKE_'

这是一个 FQL 语句,可以从 FB.api JavaScript 方法或通过任何后端 SDK 运行。

What you're looking for is the connection table. Try this:

SELECT target_id, target_type
FROM connection
WHERE source_id = '_THE_USERS_FACEBOOK_ID_'
  AND target_id = '_THE_ID_OF_THE_PAGE_OR_OBJECT_TO_LIKE_'

That is an FQL statement that can be run from the FB.api JavaScript method, or through any of the backend SDKs.

等风来 2024-09-08 10:59:49

使用 PhoneGap 的插件我可以做到这一点:

pageID = '6815841748';
FB.api('/me', function (a) {
   user_id = a.id;
   FB.api('/' + user_id + '/likes/'+pageID, function (a) {
        alert(a.data.length);
    })
});

如果他们喜欢给定的页面 ID,它将返回 1,否则返回 0。

我发现(但尚未测试)一种可能更清洁的方法:

window.checkDoesLike = function() {
  FB.api({ method: 'pages.isFan', page_id: '6815841748' }, function(resp) {
    if (resp) {
      alert('You like.');
    } else {
     alert("You don't like.");
    }
  });
};

With PhoneGap's plugin I can do this:

pageID = '6815841748';
FB.api('/me', function (a) {
   user_id = a.id;
   FB.api('/' + user_id + '/likes/'+pageID, function (a) {
        alert(a.data.length);
    })
});

It will return 1 if they like the given page ID, 0 otherwise.

I discovered (but have not tested) a possibly cleaner method:

window.checkDoesLike = function() {
  FB.api({ method: 'pages.isFan', page_id: '6815841748' }, function(resp) {
    if (resp) {
      alert('You like.');
    } else {
     alert("You don't like.");
    }
  });
};
硪扪都還晓 2024-09-08 10:59:49

目前“//likes”图表资源是唯一可用的。不过,这还不算太糟糕。

https://graph.facebook.com/ngerakines/likes?access_token=

Right now the '//likes' graph resource is the only one available. It isn't too bad though.

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