Hi,
I am having trouble creating contact into my list. Though I have added contacts on sunday successfully using same code. But since then I am unable to make it work. I am having problem. I am using Constant Contact API wrapper class from these guys.
http://integrationservic.es/constant-contact/php-developers-code.php
Here is a code
<?php // $Id$ /** * Create a new contact */ require_once '../class.cc.php'; $api_key = '14fbf002-8ddc-4a64-85ee-2accfa7d5a13'; // Set your Constant Contact account username and password below $cc = new cc('saasfreelancer', '********', $api_key); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Example Script - create_contact()</title> </head> <body> <h3>Example Script - create_contact()</h3> <p><a href="index.php">View all example scripts</a></p> <?php $email = 'syed.sayal.shah@gmail.com'; $contact_list = array(1, 2);
$extra_fields = array( 'FirstName' => 'Test', 'LastName' => 'Test', ); // check if the contact exists $contact = $cc->query_contacts($email); // uncomment this line if the user makes the action themselves //$cc->set_action_type('contact'); if($contact): // update the contact $status = $cc->update_contact($contact['id'], $email, $contact_list, $extra_fields); if($status): echo "Contact {$contact['id']} has been updated"; else: // if an error occurs we can debug it any various ways // show a simple error to the user echo "Update Contact Operation failed: " . $cc->http_get_response_code_error($cc->http_response_code); // or output the last http request and response strings, for debugging only $cc->show_last_connection(); // usually the http_response_body will contain a more descriptive error to help debug if($cc->http_response_body): echo '<p>' . $cc->http_response_body . '</p>'; endif; endif; else: // create the contact $new_id = $cc->create_contact($email, $contact_list, $extra_fields); if($new_id): echo "Contact created with ID $new_id"; else: // if an error occurs we can debug it any various ways // show a simple error to the user echo "Create Contact Operation failed: " . $cc->http_get_response_code_error($cc->http_response_code); // or output the last http request and response strings, for debugging only $cc->show_last_connection(); // usually the http_response_body will contain a more descriptive error to help debug if($cc->http_response_body): echo '<p>' . $cc->http_response_body . '</p>'; endif; endif; endif; ?> </body> </html>
Please help as soon as you can. Regards.
SAAS
I can confirm that I am also having issues adding a contact using this script, but the XML it is producing is valid and does create a contact. Since the XML works, this leads me to believe that there is a problem with the actual sending of the information. I would check to make sure that you have the following options setup as the README file requests:
PHP 4.3.0 or higher
XML extension installed and enabled
openssl extension installed and enabled
allow_url_fopen enabled in php.ini
With that being said, I am using PHP 5 which may be causing some issues since this is intended for PHP4 so I'm not sure if I am able to adequately diagnose this issue. Also, this PHP Library was created by a 3rd party not by us so my ability to troubleshoot issues with this is diminished. I will do my best to figure this issue out but I'll need to install PHP 4 on another environment and test there, which will take some time. For the quickest response, you would be better off to contact the developer of that class file.
David J