[英]How would I retrieve the latest 'x' number of posts from multiple Facebook users with the Koala gem?
我希望能夠通過FQL或Graph API從一組帶有Koala gem的Facebook用戶中返回帖子的JSON列表。 目前,我正在使用Koala的批處理功能來調用每個用戶供稿中第一個“ x”個項目,然后將其展平並按時間排序。 問題是,我希望能夠獲得第一個“ x”個項目,但它不能從每個用戶那里獲得10個,而只是從我查詢的用戶那里獲得10個最新的帖子,因此我可以檢索下一個提要中的10類似於您自己的家庭提要中所期望的。
這是我目前擁有的:
@oauth = Koala::Facebook::OAuth.new
@access_token = @oauth.get_app_access_token
@graph = Koala::Facebook::API.new(@access_token)
artists = []
followings.each do |following|
artists << following.artist
end
feed = @graph.batch do |batch_api|
artists.each do |artist|
feed | batch_api.get_connections(artist.facebook, "feed", {"limit" => "10"})
end
end
feed.flatten!
feed.sort! { |x, y| y["created_time"] <=> x["created_time"] }
編輯
我相信我已經找到了FQL的一種可能的解決方案,如下所示
batch_api.fql_query("SELECT post_id, source_id, likes, actor_id, message, type FROM stream WHERE source_id IN(artist1, artist2...)")
但是我現在返回錯誤
[#<Koala::Facebook::APIError: OAuthException: (#606) Queries for multiple source_ids require a non-zero viewer that has granted read_stream permission>]
問題是我的應用程序不需要某人登錄Facebook,因此我無法請求read_stream權限。 無論如何,Facebook應用程序本身可以提出請求嗎?
它應該可以工作,但是這里描述了一個FB錯誤:
我認為您無需采取任何措施來解決它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.