Links in the message translate into a proper link on Facebook when sending to facebook.
This commit is contained in:
parent
49bee9bf19
commit
82feff7fb4
1 changed files with 9 additions and 1 deletions
|
|
@ -9,7 +9,15 @@ class Services::Facebook < Service
|
|||
Rails.logger.debug("event=post_to_service type=facebook sender_id=#{self.user_id}")
|
||||
message = public_message(post, url)
|
||||
begin
|
||||
Faraday.post("https://graph.facebook.com/me/feed", {:message => message, :access_token => self.access_token}.to_param)
|
||||
if /https?:\/\/(.+) / =~ message
|
||||
link = /https?:\/\/(.+) /.match(message)[0]
|
||||
Faraday.post("https://graph.facebook.com/me/feed", {:message => message, :link => link, :access_token => self.access_token}.to_param)
|
||||
elsif /https?:\/\/(.+)$/ =~ message
|
||||
link = /https?:\/\/(.+)$/.match(message)[0]
|
||||
Faraday.post("https://graph.facebook.com/me/feed", {:message => message, :link => link, :access_token => self.access_token}.to_param)
|
||||
else
|
||||
Faraday.post("https://graph.facebook.com/me/feed", {:message => message, :access_token => self.access_token}.to_param)
|
||||
end
|
||||
rescue Exception => e
|
||||
Rails.logger.info("#{e.message} failed to post to facebook")
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue