Created
April 19, 2014 01:15
-
-
Save bhowe/11070570 to your computer and use it in GitHub Desktop.
Add a individual contact for constant contact using httparty in Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'bundler/setup' | |
require 'open-uri' | |
require 'httparty' | |
class Foo | |
def self.do_it | |
test = '{ | |
"lists": [ { "id": "68" }, { "id": "69" } ], | |
"email_addresses": [ { "email_address": "test@test.com" } ], | |
"first_name": "Foo", "last_name": "Bar" | |
}' | |
response = post("https://api.constantcontact.com/v2/contacts", | |
:headers => { | |
'authorization' => "Bearer INSERT YOUR ACCESS TOKEN", | |
'Content-Type'=> 'application/json' | |
}, | |
:query => { | |
'action_by' => 'ACTION_BY_OWNER', | |
'api_key' => 'INSERT YOUR API KEY' | |
}, | |
:body => test ) | |
puts response | |
end | |
end | |
Foo.do_it() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment