Class: FbGraphRuby::Messenger
- Inherits:
-
Object
- Object
- FbGraphRuby::Messenger
- Defined in:
- lib/fb_graph_ruby.rb
Class Method Summary collapse
Class Method Details
.get_profile(fb_id, access_token) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/fb_graph_ruby.rb', line 8 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
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fb_graph_ruby.rb', line 16 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 |