Skip to content

Instantly share code, notes, and snippets.

@bhowe
Created April 19, 2014 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhowe/11070570 to your computer and use it in GitHub Desktop.
Save bhowe/11070570 to your computer and use it in GitHub Desktop.
Add a individual contact for constant contact using httparty in Ruby
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