trying to authenticate using API PHP Wrapper (since I am on PHP 4.4) and got following message
HTTP Status 401 - Unable to authenticate user username
i have double checked that I have the correct API key, constant contact username and password
i am using the same username and pw as when I sign in to CC
I was specifically using 'create_contact.php' and below
is some info that was displayed wirth the error
Create Contact Operation failed: Unauthorized - This is an authentication problem. Primary reason is that the API call has either not provided a valid API Key, Account Owner Name and Associated Password or the API call attempted to access a resource (URI) which does not match the same as the Account Owner provided in the login credientials.POST /ws/customers/username/contacts HTTP/1.1 Host: api.constantcontact.com Content-Type: application/atom+xml User-Agent: justphp 2.0 Content-Length: 558 Authorization: Basic NWVjN2U3ODAtNmYyNS00NzE5LWJkYWUtZWMxZDRiMzJiZDFlJXVzZXJuYW1lOnBhc3N3b3Jk Connection: Close 2008-07-23T14:21:06.407Z data:,none Contact email@example.com ACTION_BY_CUSTOMER Firstname Lastname HTTP/1.1 401 Unauthorized Connection: close Content-Length: 54 Content-Type: text/html;charset=utf-8 Date: Wed, 06 Jul 2011 22:28:46 GMT Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate, no-cache="Set-Cookie" Pragma: no-cache Server: Apache Vary: Accept-Encoding,User-Agent WWW-Authenticate: Basic realm="api.constantcontact.com" X-Powered-By: Set-Cookie: BIGipServerProdAPI=205919242.6695.0000; path=/ HTTP Status 401 - Unable to authenticate user username
Which php wrapper are you using? The current wrappers that we have created are not compatible with php4. Currently we recommend that php4 developers use the third party php library found here. However, if the php library you are using supports php4, let me know where it is and I can take a look at it, which will give me a better idea of why you are getting a 401 error.
i am using the PHP wrapper that supports PHP 4 at
I actually now have the authentication working.
but here is another question
how do you create a custom field in a contact list with radio button choices and how do you handle using API to update the field?
I am glad to hear that the authentication part is now working! Custom fields are assigned per contact, not for the actual contact list. You would add a new custom field form field during the sign up process, and then add it to contact when you are running the function to create the contact.
In the wrapper that you are using, the function is create_contact, and it has a field for additional fields. You would want to pass it: "Custom Field 1", "Custom Field 2", etc, and it will add the contacts with those additional fields.
If you have any questions please let me know.
i tried to pass the form data into a custom field that I named 'What mobile platform do you use?:' in the contact list.
but I passed as you suggested using Custom_Field_1
Below a section of th the php code for sending data to API. I actually tried it all different variations 'Custom Field 1' 'custom_field_1' etc.
note - the other fields all go through, just not the custom field
i have tested that $customfield1 had actual post data in it captured form my form.
but nothing I do seems to make CC capture data int he customfield1 on the CC contacts detail section.
$extra_fields = array(
'FirstName' => $firstname,
'LastName' => $lastname,
'City' => $city,
'StateCode' => $statecode,
'Custom_Field_1' => $customfield1,
Maybe i did not define the custom field properly in the contact list. Could you go through exactly how to define it and where (give link if possible)
The way that library works it is "Custom Field 1" not "Custom_Field_1". Let me know if that works.
Great! Sorry for the confusion. I am not as familiar with this particular library because I mainly work with php5 and curl.
If you run into any issues let us know!