Reply
Participant
carrknowledge
Posts: 14
Registered: ‎12-12-2008

Very cool!

Well, I thought I knew what the issue was, but I am having a problem still. What exactly is the URI? The reason i ask is that this account is a contact account within a partner account. I just set up the API through the contact account but now wonder if I needed to use the Partner account. If tha tmakes any sense...



Peter
CTCT Employee
CC_TomM
Posts: 184
Registered: ‎03-07-2008

re: Very Cool (What is the URI)

The URI I am referencing is the HTTP address you are referencing in your code. In your code above, for example, this is the URI:
"http://api.constantcontact.com/ws/customers/" . $this->account_username . "/contacts";

From a permissions perspective, the value of account_username in this line MUST be the same as the username you are using for access credentials. I think your code is doing this.

However, because of the way you initialize the account_key parameter, you may be including the account_name twice in this string . Ie - you may be passing APIKey+account_username+account_username. (I am not sure what your updated code looks like now).
Can you echo out your userNamePassword parameter name and make sure that this is not the case?

Thanks,
Tom M
Group Product Manager – Content Editing
Constant Contact
Participant
carrknowledge
Posts: 14
Registered: ‎12-12-2008

Ok, found an error

Ok, so I found an error, and corrected it, now I get a result of 1. I assume this means success, since it wasn't in the error codes. Unfortunately I don't see my email address in the Awaiting Confirmation list, nor did I get an opt in email confirmation. Is there something else that I am missing? Thanks so much, you have been super helpful!
CTCT Employee
CC_TomM
Posts: 184
Registered: ‎03-07-2008

re: Ok, found an error "result of 1"

Something suspicious here Peter. "1" is not a valid response code. Perhaps you are not capturing the response code, but some other value? I expect to see some error trapping some place after your curl_exec line. Your code says:

$response = curl_exec($session);
curl_close($session);

I do not see where you are testing the HTTP response. For example, the PHP sample code has a block like this:

$response = curl_exec($session);
$httpcode = curl_getinfo($session, CURLINFO_HTTP_CODE);
curl_close($session);

if ($httpcode > 199 && $httpcode < 300)
{ echo "It works!!" ; // You might want GET the updated Contact and display it }
else
{ echo "<br> There a Problem <br>Error Code: ". $httpcode ; }

Are you (or can you) insert something like this?
Tom M
Group Product Manager – Content Editing
Constant Contact
Participant
carrknowledge
Posts: 14
Registered: ‎12-12-2008

HTTP Code

Thanks so much Tom! Hopefully this exchange is usefull to someone else some time. Anyway, my $httpcode response is 400. Which, according to that link you sent is a syntax error in the XML (most likely). Here is the XML i am using:

<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/">
<FirstName>' . $this->form_first_name . '</FirstName>
<LastName>' . $this->form_last_name . '</LastName>
<EmailAddress>' . $this->form_email . '</EmailAddress>
<CustomText4>' . $this->form_month . '</CustomText4>
<CustomText5>' . $this->form_day . '</CustomText5>
<OptInSource>ACTION_BY_CUSTOMER</OptInSource>
<ContactLists>
<ContactList id="http://api.constantcontact.com/ws/customers/' . $this->account_username . '/lists/1" />'
. '<ContactList id="http://api.constantcontact.com/ws/customers/' . $this->account_username . '/lists/2" />'
. '</ContactLists>
</Contact>
</content>
</entry>

Let me know if you seen anything in that which would cause an error. Thanks again!

Peter
CTCT Employee
CC_TomM
Posts: 184
Registered: ‎03-07-2008

re: HTTP Code (Contact Post) XML

Hi Peter,

When I make a few changes to your XML, it works for me:
1) Change CustomText4 and 5 to CustomField4 and 5
2) Verify that /lists/1 and lists/2 exist for your account
3) Put a valid value in "Updated" (This field will be populated in the POST, so you can put anything - it just has to have the right format).


This XML worked for me:

&LT;entry xmlns="http://www.w3.org/2005/Atom"&GT;
&LT;title type="text"&GT; &LT;/title&GT;
&LT;updated&GT;2008-11-07T22:35:16.497Z&LT;/updated&GT;
&LT;author&GT;&LT;/author&GT;
&LT;id&GT;data:,none&LT;/id&GT;
&LT;summary type="text"&GT;Contact&LT;/summary&GT;
&LT;content type="application/vnd.ctct+xml"&GT;
&LT;Contact xmlns="http://ws.constantcontact.com/ns/1.0/"&GT;
&LT;FirstName&GT;' . $this-&GT;form_first_name . '&LT;/FirstName&GT;
&LT;LastName&GT;' . $this-&GT;form_last_name . '&LT;/LastName&GT;
&LT;EmailAddress&GT;a1a1a2@test.com&LT;/EmailAddress&GT;
&LT;CustomField4&GT;' . $this-&GT;form_month . '&LT;/CustomField4&GT;
&LT;CustomField5&GT;' . $this-&GT;form_day . '&LT;/CustomField5&GT;
&LT;OptInSource&GT;ACTION_BY_CUSTOMER&LT;/OptInSource&GT;
&LT;ContactLists&GT;
&LT;ContactList id="http://api.constantcontact.com/ws/customers/MyAccountName/lists/52" /&GT;
&LT;/ContactLists&GT;
&LT;/Contact&GT;
&LT;/content&GT;
&LT;/entry&GT;


Thanks,
Tom M
Group Product Manager – Content Editing
Constant Contact
Participant
carrknowledge
Posts: 14
Registered: ‎12-12-2008

How do I find my list number?

Hey man, thanks so much. I made all of these changes, but I cannot find out how to find my list number. If you could help me do that, i would totally appreciate it!
CTCT Employee
CC_TomM
Posts: 184
Registered: ‎03-07-2008

re: How do I find my List Number

This resource:
http://developer.constantcontact.com/doc/contactLists
returns a collection of the Contact lists in your account.
Thanks,
Tom M
Group Product Manager – Content Editing
Constant Contact