Between 8:00 - 9:00 am ET on 10/25 we need to take our site down to make updates. We recommend logging out before 8:00am ET and not using your account during this time. Thank you for your patience while we make these important updates.

Username not found in database.

Participant

Username not found in database.

I'm using the php add contact code.

 

I want to simply add a user to list of my cleints.

 

My clients have constant contact.

 

It's a shame that CC does nto simply allow a curl post to instanly add a contact.

 

My problem is, with the php add contact I've inputted my information but I get an error:

 

"OAuth Exception: Username raverandi not found in datastore Click here to authorize"

 

Now, I don't know what to put in the user name field.

 

Is it my cleints username , or mine? If it's mine, then were do I place my cleints user name.

 

I don't have the time to dedicated the arragont reason on why CC does not opperate like other networks. I'm considering dropping CC as an option unless I find out how to do this. I've looked everywhere but can't find it. 

3 REPLIES 3
Moderator

Hey Randi,

 

Which PHP tool are you using to add the contact (Sample Contact Forms, PHP Wrapper Library, or CCSFG)? Depending on which option you are using, we can definitely provide insight as to what is needed, and why that error is coming up.

Nick Galbraith
Support Engineer

I got it working. Thank god, I was getting so frustrated last night. :smileyhappy:

 

But here's the things, heres the code im using:

 

$emailaddress = "email@email.com";

/////////// REGISTER EMAIL WITH CONSTANT CONTACT ///////////////////
$UN = "";
$PW = "";
$Key = "";
$entry = '<entry xmlns="http://www.w3.org/2005/Atom">
<title type="text"> </title>
<updated>' . date('c') . '</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/' . $UN . '/lists/1" />
</ContactLists>
</Contact>
</content>';
// Initialize the cURL session
$request ="https://api.constantcontact.com/ws/customers/" . $UN . "/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);

 

 

How do I make it for my clients? 

 

Because I don't want to ask them for their password, I see that I can do Oath 2 But where and how could I do that?

 

Is there a field I could put the auth token or?

Hello,

 

OAuth 2 is probably the simplest way, as you surmised.  It can be accomplished in just a few steps using the CTCTOauth2 class in the Authentication.php file of our PHP wrapper library, or by using another self-contained approach (like this open-source example).  The trick is then to store the access token locally, or to hard code that into your script that makes your script above.

 

To use the access token, you can then either add the following header to your curl request:

 

     Authorization:Bearer the_token

 

or, you can append it as a parameter to the request uri:

 

     ?access_token=the_token

 

(where "the_token" should obviously be replaced with the actual token). 

 

I hope this will help you get this up and running. Let us know if you run into any snags or have additional question.

 

Cheers,

Mark Coleman
Support Engineer
Developer Portal

View API documentation, code samples, get your API key.

Visit Page