通过 FQL 获取用户对流项目的喜欢(帖子、评论、图片、链接等)

发布于 2024-12-21 02:13:51 字数 1122 浏览 0 评论 0原文

我需要帮助来让用户喜欢通过 FQL 传输项目。我得到了一些喜欢,但不知道如何获得其他喜欢。对于 access_token,每一个权限都会被授予


让我向您展示我能做什么:

我在页面供稿上喜欢的帖子:

fql?q=Select post_id, source_id, message FROM流,其中 source_id in (从连接中选择 target_id,其中 source_id=me() 和 is_following=1) AND likes.user_likes=1 LIMIT 10 注意:此方法自 2011 年 12 月中旬原始问题发布时起生效。现在(2012 年 2 月中旬),它不再从页面返回任何喜欢的流内容。

我喜欢的帖子我发布的帖子

fql?q=从流中选择 post_id、source_id、消息,其中 source_id=me() AND likes.user_likes=1 LIMIT 10


这是我缺少的

帖子我在朋友的墙上点过赞:

fql?q=Select post_id, source_id, message FROM stream where source_id in (SELECT uid1 FROMfriend WHERE uid2=me()) AND likes.user_likes=1 & LIMIT 5000

我在活动墙上点赞的帖子:

????

我在活动墙上点赞的帖子群组墙

??????

I need assistance in getting user likes of stream items via FQL. I've got some of the likes coming back, but cannot figure out how to get others. For the access_token, every permission is granted.


Let me show you what I've been able to do:

postings I've liked on Page feeds:

fql?q=Select post_id, source_id, message FROM stream where source_id in (SELECT target_id FROM connection WHERE source_id=me() and is_following=1) AND likes.user_likes=1 LIMIT 10
Note: This worked as of mid Dec 2011 when the original question was posted. Now (mid Feb 2012) it is no longer returning anything liked stream content from a page.

postings I've liked of posts that I posted:

fql?q=Select post_id, source_id, message FROM stream where source_id=me() AND likes.user_likes=1 LIMIT 10


Here's what I'm missing

postings I've liked on friends' walls:

fql?q=Select post_id, source_id, message FROM stream where source_id in (SELECT uid1 FROM friend WHERE uid2=me()) AND likes.user_likes=1 & LIMIT 5000

postings I've liked on events' walls:

????

postings I've liked on groups' walls:

????

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

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

发布评论

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

评论(7

甜妞爱困 2024-12-28 02:13:51

以下是我在发布时(2012 年 10 月 22 日)得出的结论:

对于 Friends/subscribedto/pages 项目:

SELECT likes, post_id, actor_id, target_id, message
FROM stream
WHERE source_id IN (SELECT target_id FROM connection WHERE source_id=me())
AND likes.user_likes=1 

来自“喜欢”表:

SELECT user_id, object_id, post_id
FROM like
WHERE user_id=me()

post_id 始终为 null通过图形 API 查询时,有时 object_id 不存在(即 graph.facebook.com/OBJECT_ID

对于链接/外部对象 - 不存在直接获取 Facebook 帖子详细信息的方法,但它返回很多结果。也许使用另一个查询/多重查询在streamlink表中查找这些URL。

SELECT url
FROM url_like
WHERE user_id=me()

Here's what I've come up with, as of the time of posting (10-22-2012):

For friends/subscribedto/pages items:

SELECT likes, post_id, actor_id, target_id, message
FROM stream
WHERE source_id IN (SELECT target_id FROM connection WHERE source_id=me())
AND likes.user_likes=1 

OR

From 'like' table:

SELECT user_id, object_id, post_id
FROM like
WHERE user_id=me()

But post_id is always null and object_id doesn't exist sometimes when queried via the graph api (i.e. graph.facebook.com/OBJECT_ID )

For links/external objects - There is no direct way to get the facebook post details from this, but it returns a lot of results. Maybe with another query / multiquery looking for these urls in the stream or link tables.

SELECT url
FROM url_like
WHERE user_id=me()
深空失忆 2024-12-28 02:13:51

我找到了使用 Open Graph API 的解决方案。希望这对您也有帮助?

要执行此操作,您需要用户 read_stream 权限。

请告诉我我的解决方案是否满足您的要求。

由于 FQL 的支持时间不会比 V2.0 更长,因此我更喜欢使用 Open Graph API 而不是 FQL。

/*
*
*   Count my_user_id likes in wall of user "123"
*
*   ex: url = /123/posts
*   
*   setTimeout to avoid exceed api level rate limit, code 613
*/

function findMyLikes(url,my_user_id,count,callback) {
    console.log(url);
    FB.api(url, function (response) {
        if (response.data) {
            response.data.forEach(function (post) {
                //console.log(post);
                if (post.likes) {
                    post.likes.data.forEach(function (like) {
                        if (like.id == my_user_id) {
                            count++;
                        }
                    });
                }
            });
        }

        if (response.paging && response.paging.next) {
            setTimeout(function() {findMyLikes(response.paging.next,my_user_id,count,callback)},1000);
        } else {
            callback(count);
        }
    });

};

我注意到,如果您正在分析很长的提要,则此解决方案可能需要一些时间。
对于这个问题,我仍然有一个悬而未决的问题:用更少的图形 API 调用从新闻墙上的特定用户那里获取所有喜欢
https://codereview.stackexchange.com/q/58270/50013?sem=2

I found a solution using the Open Graph API. Hope this will help you also?

To perform this action you need the users read_stream permission.

Please let me know if my solution works for your requirements.

Because FQL will not be longer supported than V2.0, I would prefer using Open Graph API over FQL.

/*
*
*   Count my_user_id likes in wall of user "123"
*
*   ex: url = /123/posts
*   
*   setTimeout to avoid exceed api level rate limit, code 613
*/

function findMyLikes(url,my_user_id,count,callback) {
    console.log(url);
    FB.api(url, function (response) {
        if (response.data) {
            response.data.forEach(function (post) {
                //console.log(post);
                if (post.likes) {
                    post.likes.data.forEach(function (like) {
                        if (like.id == my_user_id) {
                            count++;
                        }
                    });
                }
            });
        }

        if (response.paging && response.paging.next) {
            setTimeout(function() {findMyLikes(response.paging.next,my_user_id,count,callback)},1000);
        } else {
            callback(count);
        }
    });

};

I noticed that this solution may take some time, if your are analyzing very long feeds.
For this issue I have still an open question pending : Getting all likes from a specific user on a news wall with fewer graph API calls
https://codereview.stackexchange.com/q/58270/50013?sem=2

就是爱搞怪 2024-12-28 02:13:51

Facebook 合作伙伴工程师 @Jeff Sherlock 表示 在这里你无法获得使用 Facebook 平台的人的所有点赞。出于隐私原因,我们将其限制为演员、电影、运动队等。我知道这没有多大意义,因为您可以使用 Facebook API 查询各种其他内容。我建议你拍 Ashton Kutcher 的照片并尝试在他的喜欢的桌子上查询......等等,你需要他的许可; ]

@Jeff Sherlock, a partner engineer at Facebook, says here that 'you cannot pull all of the likes of a person using the fb platform. We limit it to actors, movies, sports teams, etc. for privacy reasons.' I know it doesn't make much sense since you can query all kinds of other stuff with the Facebook API. I would suggest you pic Ashton Kutcher and try to query on his like table... Wait, you need his permission ; ]

九厘米的零° 2024-12-28 02:13:51

问题是 Like 表对所有内容都返回一个空白的 post_id 。但是,它确实会返回一个您喜欢的 object_id 。

您可以将所有这些 object_ids 放在逗号分隔的字符串中,然后使用 ?ids=objectid1,objectid2,objectid3 等提交图形 API 调用。

然后,这将返回它找到的所有对象。通过这种方式,您可以获得流项目的点赞。

时间似乎回到了大约4周前。我似乎无法让它比这更早。

顺便说一句,您会发现喜欢的评论也会以 object_ids 形式返回 Like 表中。然而,似乎根本没有任何方法可以找出这些 object_id 的对象详细信息。这些有点神秘。

The problem is that the like table returns a blank post_id for everything. However, it does return an object_id for your likes.

You can put all these object_ids in a comma separated string, then submit a graph API call with ?ids=objectid1,objectid2,objectid3 etc.

This will then return all the objects that it finds. This way you can get the likes for stream items.

It seems to go about 4 weeks back. I can't seem to make it go any further back than this.

As an aside, one thing you will find is that liked comments are also returned as object_ids in the like table. However, there does not appear to be any way at all to find out the object details of these object_ids. Bit of mystery with these ones.

冰魂雪魄 2024-12-28 02:13:51

如果您阅读了 like 表文档,post_id字段有一条注释,内容如下:

必须从流 FQL 表中查询这些帖子 ID。

因此,当您像 post_id<>"" 一样比较 post_id 时,它不会返回任何内容,因为默认结果包含空白 post_ids。当您运行以下查询时,似乎:

SELECT user_id, object_id, post_id
FROM like
WHERE user_id=me()

它返回用户喜欢的页面和其他一些内容,但不返回提要帖子。

由于您已经想从流表中获取点赞,因此您只想从流表中获取 post_id 。要获取给定日期 NewsFeed 的 post_id,您可能需要尝试以下查询。

SELECT post_id
FROM stream
WHERE filter_key IN (
    SELECT filter_key
    FROM stream_filter
    WHERE uid=me()
    AND type='newsfeed'
)
AND is_hidden = 0
AND description<>''

您可能需要使用 LimitCreated_time 字段来获取更多编号。的帖子。一旦您在多查询中使用上述查询来获得用户的点赞,您肯定会在某一天获得点赞。

If you read the like table documentation, post_id field has a note which reads :

These post IDs must be queried from the stream FQL table.

Hence when you compare post_id like post_id<>"", it won't return you anything as default result contains blank post_ids. And it seems when you run below query :

SELECT user_id, object_id, post_id
FROM like
WHERE user_id=me()

It returns the pages liked by user and some other stuff but not the feed posts.

As you already want to get likes from stream table, you just want to get post_id from stream table. To get post_id of NewsFeed for a given day, you might want to try below query.

SELECT post_id
FROM stream
WHERE filter_key IN (
    SELECT filter_key
    FROM stream_filter
    WHERE uid=me()
    AND type='newsfeed'
)
AND is_hidden = 0
AND description<>''

You might want to use Limit and Created_time fields to get more no. of posts. And once you use above query in Multi-query to get likes for the user, you'll definitely get likes for a given day.

孤星 2024-12-28 02:13:51
SELECT post_id, actor_id, message, type, permalink, attachment, likes, 
    comments, description, updated_time, created_time
FROM stream 
WHERE filter_key in (
        SELECT filter_key 
        FROM stream_filter 
        WHERE uid=me() AND type='newsfeed'
)

只需根据您的要求更改类型

SELECT post_id, actor_id, message, type, permalink, attachment, likes, 
    comments, description, updated_time, created_time
FROM stream 
WHERE filter_key in (
        SELECT filter_key 
        FROM stream_filter 
        WHERE uid=me() AND type='newsfeed'
)

just change type on your requirement

倾城花音 2024-12-28 02:13:51

这是 GraphAPI 不可能实现的。 GraphAPI 将允许您查看用户通过 /me/likes 点赞的页面,但它不会为您提供发布到用户的所有项目的列表。他们喜欢的墙。

您可以在 Facebook 文档中查看相关详细信息。

我对您的问题中列出的 FQL 没有任何经验,但 Stack Overflow 问题似乎可以为您的问题提供答案。

请参阅:Facebook API -“我的所有喜欢”查询

在测试中完美运行。

This is not possible with the GraphAPI. The GraphAPI will allow you to see the pages that a user has liked with /me/likes, but it will not give you a list of all the items posted to the user's wall that they haved liked.

You can see details on this in the Facebook Documentation.

I have no experience with FQL as listed in your question, but a Stack Overflow question seems to provide an answer to your question.

See: Facebook API - "All my likes" query

Worked perfectly in testing.

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