Reply
Occasional Participant
MehradN
Posts: 3
Registered: ‎05-01-2011

Stuck on 401 Error using PHP library (ctctWrapper)

I am using the ctctWrapper library in Drupal and I am sure the api information is correct - its pretty straight forward per the library (The login ID, Password, and API key are all correct).

 

The background on this is that we have some special features in our website that allows users to create drupal user logins automatically and in conjunction with these actions, we are using standard Drupal hooks to interface these new contacts to Constant Contact.

 

In my code,

  ,  I create a parameter array containing only email address, name, and list array.

  ,  I instantiate a new Contact object by passing the parameter array

  ,  I instantiate a new ContactCollection object

  ,  I call the member function to createContact by passing the contact object

 

But I keep getting a 401 return.

 

Here is the code:

        $list_id_special  = 12;
	$list_id_general  	=  1;
	$list         = array($list_id_special, $list_id_general);   //Create array to hold the two CC lists to subscribe to
	$added_fields = array("first_name" => $firstName, "last_name" => $lastName, "email_address" => $email, "lists" => $list);  //  parameters to send to Contact object
	
	$contact = new Contact($added_fields);   			//  Just the basic parameters only, not all
	if (is_object($contact)) {
		// great we have a constant contact object, we can proceed
		$collection = new ContactsCollection($contact);  // this object has the member function to create contact
		
	    $status = $collection->createContact($contact);           // have the CC wrapper do the work of creating contact
		watchdog('constant_contact_custom-status', "constant_contact_custom status ($status for $email ) return",  array('name' => $name, '%email' => $email, 'transid' => $status), severity = WATCHDOG_NOTICE);
	}
	else {
		return ('CC-Error 1123');    // linkage to ConstantContact not working report this fixed error
	}
	
	return ('ok');
	//END constant_contact_custom Lead Submission	

Again, I am very sure that the api login, password, and key are correct. Any Help is much appreciated.  It might be I am using the wrapper lib incorrectly.   Also if it helps in finding the problem, our site is hosed on GoDaddy (this host has caused problems in past).

CTCT Employee
bsoder
Posts: 440
Registered: ‎06-05-2009

Re: Stuck on 401 Error using PHP library (ctctWrapper)

Hello,

 

I would like to help you with the issue that you are getting a 401 error when using the php wrapper.  Usually 401 errors mean that there is an access issue with the API.  I have looked over your code just in case and I do not see anything that would be giving that error message.

 

Is it possible for you to send me your username?  I can then look at your account and see if there is any reason that this is happening.  It also may be helpful for you to send me to ctctwrapper.php file you are using.  If you could send this information to webservices.

 

Regards,

Benjamin Soder
NOC Analyst
Constant Contact
Occasional Participant
MehradN
Posts: 3
Registered: ‎05-01-2011

Re: Stuck on 401 Error using PHP library (ctctWrapper)

Benamin, thanks for helping.   I sent you the details at the webservices address you provided.  Looking forward to your support on this.

Occasional Participant
MehradN
Posts: 3
Registered: ‎05-01-2011

Re: Stuck on 401 Error using PHP library (ctctWrapper)

Benjamin,   I was under the impression you would look at the info and code that I sent at your request and get back to me or reply to this post.   Could you or someone at Constant Contact (or user community) please help get past this impasse?  

 

I am sure this must be a minor item that simply needs clarification to fix.  

 

Has anyone had any success in getting past the 401 error using the PHP library supplied by CC?

CTCT Employee
bsoder
Posts: 440
Registered: ‎06-05-2009

Re: Stuck on 401 Error using PHP library (ctctWrapper)

Hi,

 

I apologize for the delay.  I am not sure if the email was filtered out by our ticketing system, but I was not able to find anything in our ticketing database with your name on it.  I am going to send you a private message now so that we can get your username and help you resolve this as soon as possible!

 

Regards,

Benjamin Soder
NOC Analyst
Constant Contact