Hi there,
I'm not able to migrate properly, and I thought I updated the code properly. Can you help? Here's the code:
Thank you,
Andrew
if (empty($errmsg)) {
$output='';
if (LOGFILE && LOG_LEVEL == 2) error_log(date('Y-m-d H:i:s') .
' Request data: ' . $entry .
"\n", 3, LOGFILE);
//$list_resp = $ct->FindContactList("Friends");
$request = "https://api.constantcontact.com/ws/customers/".CC_USERNAME."/contacts";
$session = curl_init($request);
// Set up Digest authentication - username and password.
$userNamePassword = CC_APIKEY."%".CC_USERNAME.":".CC_PASSWORD;
curl_setopt($session, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($session, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($session, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($session, CURLOPT_USERPWD, $userNamePassword);
curl_setopt($session, CURLOPT_FOLLOWLOCATION ,1);
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, 0); // Do not return headers
curl_setopt($session, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($session);
curl_close($session);
if (!$response) {
// curl failed, create error message
$output .= "
<h1>Oops!</h1>
<p>There was an error trying to connect to the server. <br />
Please go <strong><a href=\"#\" onClick=\"history.go(-1)\">BACK</a></strong> and try again later.</p>
";
My code is exactly the same as above somebody please help -
Are you receiving any error messages when attempting to send your data through? Your code is set up correctly on the php side, most likely there is a curl or server setting that is not correct. An error message will point us in a better directiong.
Hi there,
Where do I look for an error? The only error I get is the one coded into the PHP file:
"Oops!
There was an error trying to connect to the server.
Please go BACK and try again later."
If you can describe what I can do to look, that would be great. I'd also do a screen share with someone if that could resolve it quickly.
Thank you,
andrew
Looking at your code snippet more, though it seems incomplete as it doesn't check for error codes, you only should see that error oops message if there is no response code to the curl_exec command. This would indicate that the operation failed to connect to Constant Contact entirely. If we sent back an error message, $response would not be empty, it would contain an error code and message form us and you would not see that message at all.
Hi Dave,
What's my next step then?
Thanks
Andrew
Hi Dave,
I just realized my form is working when a new email address is entered. The error I showed you is happening when an existing email address is entered. What do I need to adjust to have it show the right message when the existing email address is entered?
Thanks!
Andrew
Existing contacts must be handled differently. A POST is only used for creating in REST based APIs. To update, you will need to do a PUT with a well formed update to the contact URI, not the contacts collection. For more information on how to do this, please see the Contacts Collection documentation.