Class: FbGraphRuby::Messenger
- Defined in:
- lib/fb_graph_ruby/messenger.rb
Class Method Summary collapse
Methods inherited from Base
Class Method Details
.get_profile(fb_id, access_token) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/fb_graph_ruby/messenger.rb', line 4 def self.get_profile(fb_id, access_token) uri = "https://graph.facebook.com/v2.9/#{fb_id}" query = { fields: 'first_name,last_name,locale,timezone,gender', access_token: access_token} HTTParty.get(uri, query: query).parsed_response end |
.send_message(fb_id, payload, access_token) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/fb_graph_ruby/messenger.rb', line 12 def self.(fb_id, payload, access_token) uri = "https://graph.facebook.com/v2.9/me/messages" query = { access_token: access_token } headers = { 'Content-Type' => 'application/json' } body = { recipient: { id: fb_id }, message: payload }.to_json HTTParty.post(uri, query: query, headers: headers, body: body).parsed_response end |