I am looking for the most basic way to insert a contact into CC using php. I know am having an issue trying to get the oauth2 code I found online to work (not sure how to get the tocken and then hard code it into my code)
So I am trying to use the below php but my issue is no new contact is actually being inserted so does CC not allow something as basic as the below code??
[code]
$emailaddress = "s@yahoo.com"; //yes hard coding this for testing purposes. $UN = "removed"; $PW = "removed"; $Key = "removed"; $entry = '<entry xmlns="http://www.w3.org/2005/Atom"> <title type="text"> </title> <updated>2012-12-18T19:29:06.096Z</updated> <author></author> <id>data:,none</id> <summary type="text">Contact</summary> <content type="application/vnd.ctct+xml"> <Contact xmlns="http://ws.constantcontact.com/ns/1.0/ "> <EmailAddress>' . $emailaddress . '</EmailAddress> <OptInSource>ACTION_BY_CONTACT</OptInSource> <ContactLists> <ContactList id="http://api.constantcontact.com/ws/customers/removed/lists/13 " /> </ContactLists> </Contact> </content>'; // Initialize the cURL session $request ="https://api.constantcontact.com/ws/customers/removed/contacts"; $session = curl_init($request); // Set up digest authentication $userNamePassword = $Key . '%' . $UN . ':' . $PW ; // Set cURL options curl_setopt($session, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($session, CURLOPT_USERPWD, $userNamePassword); curl_setopt($session, CURLOPT_POST, 1); curl_setopt($session, CURLOPT_POSTFIELDS , $entry); curl_setopt($session, CURLOPT_HTTPHEADER, Array("Content-Type:application/atom+xml")); curl_setopt($session, CURLOPT_HEADER, false); // Do not return headers curl_setopt($session, CURLOPT_RETURNTRANSFER, 1); // If you set this to 0, it will take you to a page with the http response // Execute cURL session and close it $response = curl_exec($session); curl_close($session);
[/code]
All I want to do is via Curl insert basic contact info into constant contact I rather not have to use a big library with a dozen files in it. Suggestions Or can someone point me to a tutorial on hopw to generate a 0auth2 token so I can then hard code it into the php library that references a CTCTDataStore()
Thanks
... View more