Class: SecondHandler::FbGroupPost

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

Instance Method Summary collapse

Constructor Details

#initialize(access_token, group_id) ⇒ FbGroupPost

Returns a new instance of FbGroupPost.



6
7
8
9
# File 'lib/second_handler.rb', line 6

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

Instance Method Details

#first_pageObject



11
12
13
# File 'lib/second_handler.rb', line 11

def first_page
  @feed = @graph.get_connections(@group_id, "feed", :fields => ["attachments{media,subattachments{media}}","id","message","updated_time"])
end

#get_contentObject

return feed of current page infomation , including image



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/second_handler.rb', line 24

def get_content
  @feed.map do |item|
    tmp = Hash.new
    tmp["id"] = item["id"]
    tmp["message"] = item["message"]
    tmp["updated_time"] = item["updated_time"]
    tmp["attachments"] = attachment_helper(item["attachments"])
    tmp
  end

end

#next_pageObject



15
16
17
# File 'lib/second_handler.rb', line 15

def next_page
  @feed = @feed.next_page
end

#previous_pageObject



19
20
21
# File 'lib/second_handler.rb', line 19

def previous_page
  @feed = @feed.previous_page
end