使用Koala(Ruby)收集用户的新闻提要 [英] Gathering a user's news feed with Koala (Ruby)

查看:104
本文介绍了使用Koala(Ruby)收集用户的新闻提要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在用户经过身份验证后拉入新闻提要.我正在使用考拉宝石,但是如果我调用get_connection('me', 'feed'),它只会返回我墙上的最后三个帖子. .我希望显示在用户主页上的最后〜100个帖子(或自1234567之后).

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.

推荐答案

您可以使用FQL在特定时间内获取所有帖子.这是一个应该让您入门的示例:

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")

此处借用的代码.

这篇关于使用Koala(Ruby)收集用户的新闻提要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆