Skip to content

Instantly share code, notes, and snippets.

@Aerlinger
Last active April 13, 2016 16:06
Show Gist options
  • Save Aerlinger/d78b62fe91e16f9deec9e11f65717e5f to your computer and use it in GitHub Desktop.
Save Aerlinger/d78b62fe91e16f9deec9e11f65717e5f to your computer and use it in GitHub Desktop.
require "active_support/all"
require "net/http"
token = "my_token"
url = "https://graph.facebook.com/v2.6/me/messages?"
sender = 100688998246663
text = "Hello"
request_params = {
recipient: {id: sender},
message: {text: text},
access_token: token
}
uri = URI.parse(url)
response = Net::HTTP.new(uri.host, uri.port)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' =>'application/json'})
request.body = request_params.to_json
http.request(request)
response = http.request(request)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment