class Messenger::Client

Public Class Methods

get_user_profile(user_id) click to toggle source
# 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}?access_token=#{Messenger.config.page_access_token}",
  ))
end
send(data) click to toggle source
# File lib/messenger/client.rb, line 9
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