Gathering a user's news feed with Koala (Ruby)

China☆狼群 提交于 2019-12-10 21:41:17

问题


I want to pull in a user's newsfeed after they have authenticated. I am using the Koala gem but if I call get_connection('me', 'feed') it only returns the last three posts on my wall. I want the last ~100 posts (or since post 1234567) that would show up on the user's home page.


回答1:


You can get all posts during a certain time period using FQL. Here is an example that should get you started:

@feed = Koala::Facebook::API.new(current_user.token)
to = Time.now.to_i
yest = 1.day.ago.to_i
@feed.fql_query("SELECT post_id, actor_id, target_id, message, likes FROM stream WHERE source_id = me() AND created_time > #{yest} AND created_time < #{to} AND type = 80 
AND strpos(attachment.href, "youtu") >= 0")

require 'koala'
@graph = Koala::Facebook::API.new("YOUR_ACCESS_TOKEN")
@graph.fql_query("SELECT post_id, actor_id, target_id, message FROM stream WHERE source_id = me() AND created_time > START_TIME AND created_time < END_TIME LIMIT 10")

Code borrowed from here.



来源:https://stackoverflow.com/questions/11217761/gathering-a-users-news-feed-with-koala-ruby

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!