Class: SecondHandler::FbGroupPost

Inherits:
Object
  • Object
show all
Includes:
FbDataHandler
Defined in:
lib/second_handler.rb

Constant Summary collapse

FB_POSTS_FIELDS =
[
  "attachments{media,subattachments{media}}",
  "id",
  "message",
  "updated_time",
  "from{id,name,picture}",
  "comments.summary(1)",
  "likes.summary(1)"
]

Constants included from FbDataHandler

FbDataHandler::FACEBOOK_URL

Instance Method Summary collapse

Constructor Details

#initialize(access_token, group_id) ⇒ FbGroupPost

Returns a new instance of FbGroupPost.



79
80
81
82
# File 'lib/second_handler.rb', line 79

def initialize (access_token, group_id)
  @graph = Koala::Facebook::API.new(access_token)
  @group_id = group_id
end

Instance Method Details

#first_page(page_token = nil, until_stamp = nil) ⇒ Object



84
85
86
# File 'lib/second_handler.rb', line 84

def first_page(page_token=nil,until_stamp=nil)
  @feed = @graph.get_connections(@group_id, "feed",:fields => FB_POSTS_FIELDS )
end

#get_content(&func) ⇒ Object

return feed of current page infomation , including image



115
116
117
118
119
# File 'lib/second_handler.rb', line 115

def get_content (&func)
  @feed.to_a.map do |single_post|
    clean_post_content(single_post)
  end
end

#next_pageObject



98
99
100
# File 'lib/second_handler.rb', line 98

def next_page
  @feed = @feed.next_page
end

#next_page_paramsObject



102
103
104
# File 'lib/second_handler.rb', line 102

def next_page_params
  @feed.next_page_params
end

#previous_pageObject



110
111
112
# File 'lib/second_handler.rb', line 110

def previous_page
  @feed = @feed.previous_page
end

#previous_page_paramsObject



106
107
108
# File 'lib/second_handler.rb', line 106

def previous_page_params
  @feed.previous_page_params
end

#specified_page(page_token, until_stamp = nil, since_stamp = nil) ⇒ Object



88
89
90
91
92
93
94
95
96
97
# File 'lib/second_handler.rb', line 88

def specified_page (page_token,until_stamp=nil,since_stamp=nil)
  
  @feed = @graph.get_connections(@group_id, "feed",
    :__paging_token => page_token,
    :until => until_stamp,
    :since => since_stamp,
    :fields => FB_POSTS_FIELDS
    )

end