Class: Messenger::Client
- Inherits:
-
Object
- Object
- Messenger::Client
- Defined in:
- lib/messenger/client.rb
Class Method Summary collapse
Class Method Details
.get_user_profile(user_id) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/messenger/client.rb', line 3 def self.get_user_profile(user_id) JSON.parse(RestClient.get( "https://graph.facebook.com/v2.6/#{user_id}?fields=first_name,last_name,profile_pic \ &access_token=#{Messenger.config.page_access_token}", )) end |
.send(data) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/messenger/client.rb', line 10 def self.send(data) RestClient.post( "https://graph.facebook.com/v2.6/me/messages?access_token=#{Messenger.config.page_access_token}", data.build.to_json, content_type: :json ) rescue RestClient::ExceptionWithResponse => err puts "\nFacebook API response from invalid request:\n#{err.response}\n\n" end |