Skip to content

Commit 67abede

Browse files
author
Oreonax
committed
Set Facebook Graphapi version to latest: 2.9
1 parent 6c92a20 commit 67abede

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

_plugins/social_wall/social_networks/facebook.rb

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def created_time
2121

2222
def self.new_connection
2323
@graph = Koala::Facebook::API.new(ENV['FACEBOOK_ACCESS_TOKEN'])
24+
Koala.config.api_version = "v2.9"
2425
end
2526

2627
def self.get(meth, username, amount)
@@ -34,7 +35,7 @@ def self.get(meth, username, amount)
3435
end
3536

3637
def self.connections(username, count)
37-
@graph.get_connections(username,'posts',{limit: count})
38+
@graph.get_connections(username,'posts',{limit: count, fields: ['object_id', 'message', 'message_tags', 'id','type', 'from', 'picture', 'link', 'created_time', 'status_type', 'caption', 'name', 'description']})
3839
end
3940

4041
def self.get_object(object)
@@ -76,7 +77,7 @@ def has_photo?
7677
end
7778

7879
def photo
79-
data = FB.get_object(@post['object_id'])
80+
data = FB.get_object(@post['object_id'] +'?fields=width,height,source')
8081
src_full = FB.get_picture_data(@post['object_id'], 'normal')['data']['url'] if @post['type'] == 'photo'
8182
src_full = FB.get_object(@post['object_id'] +'?fields=cover')['cover']['source'] if @post['type'] == 'event'
8283

@@ -104,7 +105,7 @@ def video
104105
video['link'] = @post['link']
105106
video['id'] = /\/videos\/(?:t\.\d+\/)?(\d+)/i.match(@post['link'])[1]
106107

107-
picture_formats = FB.get_object(video['id'])['format']
108+
picture_formats = FB.get_object(video['id'] +'?fields=format')['format']
108109
i_avg = (picture_formats.length.to_f/2).round # get the average quality
109110

110111
video['picture'] = picture_formats[i_avg-1]['picture']
@@ -162,20 +163,20 @@ def ext_quote_picture
162163
def ext_quote
163164
quote = Hash.new
164165
quote['link'] = @post['link']
165-
quote['picture'] = has_ext_quote_picture? ? ext_quote_picture : get_url_best_picture(quote['link'])
166+
quote['picture'] = get_url_best_picture(quote['link'])
166167
quote['source'] = @post['caption']
167168
quote['title'] = @post['name']
168169
quote['description'] = @post['description']
169170

170171
return quote
171172
end
172173

173-
# Message
174-
175174
def has_message_tags?
176175
@post.has_key?('message_tags')
177176
end
178177

178+
# Message
179+
179180
def has_message?
180181
@post.has_key?('message')
181182
end
@@ -187,10 +188,8 @@ def parse_message(text="")
187188
text = text.gsub(/\#([a-z0-9âãäåæçèéêëìíîïðñòóôõøùúûüýþÿı_-]+)/i, '<a class="hashtag" href="https://www.facebook.com/hashtag/\1">#\1</a>')
188189
# Page, Group, user
189190
if has_message_tags?
190-
@post['message_tags'].each do |k, v|
191-
v.each do |h|
192-
text = text.gsub(/\s(#{h["name"]})\s/, " <a class='mention' href='https://www.facebook.com/#{h["id"]}'>@#{h["name"]}</a> ")
193-
end
191+
@post['message_tags'].each do |tag|
192+
text = text.gsub(/\s(#{tag["name"]})\s/, " <a class='mention' href='https://www.facebook.com/#{tag["id"]}'>@#{tag["name"]}</a> ")
194193
end
195194
end
196195

@@ -200,7 +199,7 @@ def parse_message(text="")
200199
# Infos
201200

202201
def user_info
203-
username = FB.get_object(@post['from']['id'])['username']
202+
username = FB.get_object(@post['from']['id'] +'?fields=username')['username']
204203
picture = FB.get_picture_data(@post['from']['id'], 'normal')
205204

206205
user = Hash.new

0 commit comments

Comments
 (0)