通过 Open Graph 检索喜欢某个 URL/网页的 Facebook 用户
有没有办法检索在外部网站上单击“赞”按钮的 Facebook 用户列表?
- 例如,有一个域 example.com 已通过 Facebook Insights 属于fbUser1(使用 OG 元标记 )。
- example.com 上的某个页面有多个类似 XFBL 的按钮,每个按钮都指向 example.com 上的更具体的 URL,例如 example.com/ xyz、example.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 (其中 APPID 和 APPSECRET 取自使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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.
这是不可能的。 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/