class FbGraphRuby::Messenger

Public Class Methods

get_profile(fb_id, access_token) click to toggle source
# 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) click to toggle source
# File lib/fb_graph_ruby.rb, line 16
def self.send_message(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