通过 Open Graph 检索喜欢某个 URL/网页的 Facebook 用户

发布于 2024-10-15 11:58:23 字数 2053 浏览 3 评论 0原文

有没有办法检索在外部网站上单击“赞”按钮的 Facebook 用户列表?

  • 例如,有一个域 example.com 已通过 Facebook Insights 属于fbUser1使用 OG 元标记 )。
  • example.com 上的某个页面有多个类似 XFBL 的按钮,每个按钮都指向 example.com 上的更具体的 URL,例如 example.com/ xyzexample.com/abc 等。

我想获得的是喜欢 example.com/xyz 的用户列表以及喜欢example.com/abc的人。

我的直觉方法是查看graph.facebook.com/123456789/likes (其中数字是从 FB Insights 获取的域 ID),但这总是返回一个空数据集:

{
   "data": [

   ]
}

我还尝试从 https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=APPID&client_secret=APPSECRET (其中 APPIDAPPSECRET 取自使用 OG 元标记标记为拥有该域的 FB 应用程序),但这没有什么区别。

我也对非 OpenGraph(即 JS SDK、FQL 等)解决方案感兴趣。

编辑:使用以下代码(根据WideBlade答案如下)仍然给了我一个空的喜欢列表(第二个查询永远不会返回):

var objectsQuery = "select id from object_url where url in ('http://example.com/xyz', 'http://example.com/abc', 'http://example.com/123')";
var likesQuery = "select object_id from like where object_id = {0}";

FB.Data.query(objectsQuery).wait(function (objectRows) {
    console.log(objectRows);

    FB.Array.forEach(objectRows, function (objectRow) {
        FB.Data.query(likesQuery, objectRow.object_id).wait(function (likeRows) {
            console.log(likeRows);
        })
    });
});

Is there a way to retrieve the list of Facebook users that have clicked the like button on an external website?

  • E.g. there is a domain example.com which has been confirmed via Facebook Insights to belong to fbUser1 (using OG meta tags).
  • Somewhere on example.com there is a page with multiple XFBL like buttons, each one pointing to a further specific URL on example.com, e.g. example.com/xyz, example.com/abc etc.

What I'd like to get is the list of users that liked example.com/xyz and of those who liked example.com/abc.

My intuitive approach would be to look at graph.facebook.com/123456789/likes (where the number is the ID of the domain taken from FB insights), but this always returns an empty dataset:

{
   "data": [

   ]
}

I've also tried getting an OAuth access token from https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=APPID&client_secret=APPSECRET (where APPID and APPSECRET are taken from a FB application that is marked as owning the domain using OG meta tags), but that makes no difference.

I'd also be interested in a non-OpenGraph (i.e. JS SDK, FQL etc.) solution.

EDIT: Using the following code (according to WideBlade's answer below) still gives me an empty list of likes (the second query never returns):

var objectsQuery = "select id from object_url where url in ('http://example.com/xyz', 'http://example.com/abc', 'http://example.com/123')";
var likesQuery = "select object_id from like where object_id = {0}";

FB.Data.query(objectsQuery).wait(function (objectRows) {
    console.log(objectRows);

    FB.Array.forEach(objectRows, function (objectRow) {
        FB.Data.query(likesQuery, objectRow.object_id).wait(function (likeRows) {
            console.log(likeRows);
        })
    });
});

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

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

发布评论

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

评论(2

坐在坟头思考人生 2024-10-22 11:58:23

FQL 应该可以解决问题。

$facebook->api_client->fql_query('SELECT user_id FROM like WHERE object_id="OBJECTID"');

这是链接。

一些有关 FQL 的一般信息。

FQL 是使用 JavaScript SDK 启动的,以这种方式。

如果您可以发布一些示例代码,我可以尝试提供一些更具体的帮助。

应该注意的是,一旦您获得了用户 ID,您就可以查询名称并将它们放入列表中。

编辑:要获取对象的 URL,您应该查询此对象使用 fql 的表

FQL Should do the trick.

$facebook->api_client->fql_query('SELECT user_id FROM like WHERE object_id="OBJECTID"');

Here is the link.

Some general info about FQL.

FQL is initiated using the JavaScript SDK, in this way.

If you can post some sample code-I can try and give some more specific help.

A note should be made-once you've got the user ID's, you can just query the names and get them in a list.

EDIT: To get the URL of an object you should query this table using fql.

苄①跕圉湢 2024-10-22 11:58:23

这是不可能的。 Facebook 不允许您查询喜欢某个页面的人的特定用户 ID。这是出于隐私考虑。

请参阅本页上的免责声明 https://developers.facebook.com/docs/reference/ fql/喜欢/

This cannot be done. Facebook does not allow you to query for specific user ID's of people who have liked a certain page. This is because of privacy concerns.

See the disclaimer on this page https://developers.facebook.com/docs/reference/fql/like/

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