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.



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

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

Instance Method Details

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



108
109
110
# File 'lib/second_handler.rb', line 108

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



139
140
141
142
143
144
145
146
147
148
# File 'lib/second_handler.rb', line 139

def get_content (&func)
  data = Array.new
  @feed.to_a.each do |single_post|
    begin
      data << clean_post_content(single_post, &@message_parser)
    rescue
    end
  end
  data
end

#next_pageObject



122
123
124
# File 'lib/second_handler.rb', line 122

def next_page
  @feed = @feed.next_page
end

#next_page_paramsObject



126
127
128
# File 'lib/second_handler.rb', line 126

def next_page_params
  @feed.next_page_params
end

#previous_pageObject



134
135
136
# File 'lib/second_handler.rb', line 134

def previous_page
  @feed = @feed.previous_page
end

#previous_page_paramsObject



130
131
132
# File 'lib/second_handler.rb', line 130

def previous_page_params
  @feed.previous_page_params
end

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



112
113
114
115
116
117
118
119
120
121
# File 'lib/second_handler.rb', line 112

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