Constant Contact wants to help you succeed! We’re celebrating our professional service programs on the Constant Contact Community this month and you have a chance to try one of the services for free! Learn more.
I'm using the PHP wrapper provided in the Dev Network. Yesterday it was working fine -- listing my events as desired. Today I'm receiving the following error:
Warning: Invalid argument supplied for foreach() in/home/content/99/6955199/html/castalia/wp-content/themes/castalia/ctctWrapper.php on line2962
I just downloaded the wrapper again and uploaded it to my site. The only settings I changed in the wrapper are the APIKey, path, username and password.
Can you tell me why this is no longer working?
That is the part of the wrapper where starts to grab the content out of the XML. This typically happens when the wrong parameters are passed into it. Can you provide me with some of the code that you are using to pass through the wrapper?
Here's the code I'm using to retrieve the events and display them:
$data = new EventCollection();
$events = $data->listEvents();
foreach($events as $event)
$status = $event->getStatus();
$link = $event->getLink();
$title = $event->getTitle();
$oeidk = str_replace('/ws/customers/ondina/events/','',$link);
$startdate = new DateTime($event->getStartDate());
$enddate = new DateTime($event->getEndDate());
$date = new DateTime($event->getStartDate());
$date = $date->format('Y-m-d h:s');
$weekday = date('l', strtotime($date));
print '<a href="/castalia/courses/course-details?oeidk='.$oeidk.'">'.$event->getName().'</a><br />';
print ''.$weekday.'s -- '.$startdate->format('h:s a').' - '.$enddate->format('h:s a').'<br />';
print ''.$startdate->format('F d').' - '.$enddate->format('F d, Y').'<br />';
print '<i>'.$event->getDescription().'</i><br />';
print '<br />';
Actually, it looks like I'm receiving a 500 error from the API. I just printed the array returned when the ctctWrapper returns from attempting to establish a connection.
$utility = new Utility();
$return = $utility->httpGet($utility->getApiPath() . '/ws/customers/'. $utility->getLogin() .'/events');
Array ( [xml] => [info] => Array ( [url] => https://api.constantcontact.com/ws/customers/ondina/events [content_type] => [http_code] => 500 [header_size] => 0 [request_size] => 322 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 3.575343 [namelookup_time] => 3.2E-5 [connect_time] => 3.09507 [pretransfer_time] => 3.399938 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => 0 [upload_content_length] => 0 [starttransfer_time] => 3.575322 [redirect_time] => 0 ) [error] => The requested URL returned error: 500 )
Account username = 'ondina'
I was able to recreate the fact that there may be an issue with the events collection in the ctct wrapper. I am going to take a look at this now.
We do have a new library though, that definitely works, and also has better documentation. Please take a look at it here. There is also a wiki, with specific documentation to the event collection here.
If you have any questions please let me know.
The new library isn't fixing the problem for me either.
If I try basic authentication then I receive the following: "Constant Contact HTTP Request Exception: HTTP Status 500".
If I try oauth authentication then I receive the following: "OAuth Exception: Username ondina not found in datastore Constant Contact HTTP Request Exception: HTTP Status 401 - Invalid token"
Here's the code I'm using for testing purposes:
$username = 'ondina';
$password = 'xxxxxxxxx';
$apiKey = 'xxxx-xxxx-xxxx-xxxx-xxxx';
$consumerSecret = 'xxxxx';
//$ConstantContact = new ConstantContact('basic', $apiKey, $username, $password);
$ConstantContact = newConstantContact('oauth', $apiKey, $username, $consumerSecret);
$events = $ConstantContact->getEvents();
I think the problem must be related to my account itself. Even when I try to access the API through the browser (https://api.constantcontact.com/ws/customers/ondina/events) and pass APIKey + % + username with my password, I receive a 500 error back.
Is there any solution for this today? I have to demo the site to the client tomorrow.
I have looked into your issue and it looks like there may be a defect with our API with getting a list of events. We are currently working on a fix right now but as a work around you can go into your account and restore any deleted events. By doing so you should not receive any 500 errors.
I can't do that. Those events were test events and need to be permanently removed before we go live with our site. Is there any way someone at CC could permanently remove those events so they no longer crash the API?
Currently the only work around for this defect is to restore the events. However, our engineers are aware how important this is, and are working to correct this problem as soon as possible. Once the defect has been fixed, I will post an update here letting you know that it has been resolved.
If you have any questions please let me know.
Thanks Benjamin. I can confirm that restoring the events has fixed the error in ctctWrapper.
Can you give me any idea of a timeframe for an actual fix? A week? A month? I just need to know what sort of timeline to relay to my client.