Created
January 9, 2011 11:17
-
-
Save over/771608 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Получение коментов от фейсбука происходит через FQL, табличка comments_info | |
# Нужен гем facebooker, у меня для третьих рельсов: | |
gem 'facebooker', :git => "git://github.com/joren/facebooker.git", :branch => "rails3" | |
# Делаете модуль, в котором хранятся все настройки: | |
module Facebook | |
CONFIG = { | |
:app_id => "123123", | |
:api_key => "123123", | |
:app_secret => "123123" | |
} | |
def self.session | |
Facebooker::Session.new(CONFIG[:api_key], CONFIG[:app_secret]) | |
end | |
end | |
# Сам код для получения кол-ва комментариев | |
session = Facebook.session | |
data = session.fql_query("select xid, count from comments_info where app_id='#{Facebook::CONFIG[:app_id]}'") | |
# Вернет массив, вида ["your_post_xid", 123], ["your_post_2_xid", 12331] и т.д. | |
# Соответственно нужно кешировать в базе xid поста на фейсбуке | |
# Можно запихнуть или в rake-таск по крону, или завернуть в демон, | |
# получать кол-во комментов ко всем постам раз в сколько-то времени |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment