cancel
Showing results for 
Search instead for 
Did you mean: 

Bulk activity reports

SOLVED
Highlighted
All Star

Bulk activity reports

Hi everyone.

 

I have a small PHP script to synchronize my Constant Contact Lists with an external database. I make use of a ClearLists Activity and a CreateContacts activity to perform the task. The script has been running on a daily basis for the last 6 months without a problem.

 

With the previous (and in my opinion more straightforward) look & feel, I could go to

 

Contacts -> Activity

 

and I would get a list of ALL the activities in my account, with the possibility to check the errors and all that.

 

With the current look & feel, if I go to the same section, I get a report of the Import and Export activities, and ONLY those activities, but since my script makes use of two bulk activities different from Import and Export, I am getting no information on the status of my activities.

 

Is there a way to check the status of ALL bulk activities, and not only Import / Export ones, as I could do before the change?

 

Thanks in advance for the responses.

 

--

Salva

Tags (2)
9 REPLIES 9
Moderator

Re: Bulk activity reports

In the new Contacts Management System, we do not currently display the activities created through the API.  The CMS team is aware of this issue and working on a fix.  We hope to have it out in the next 4-8 weeks as we're doing a lot of work around performance.

 

However, all of the activities are still available to be monitored and looked at through the API.  We have a collection of all activities and the status/error rates of them on this API endpoint: http://developer.constantcontact.com/docs/bulk_activities_api/bulk-activities-summary-report-api.htm...

 

In the PHP SDK, you would use the method:

 

public function getActivities($accessToken, array $params = array())

 

That will return an array of all the current Activities, which is basically everything you created in the past 14 days.  This will include the status.

Dave Berard
Senior Product Manager, Constant Contact
All Star

Re: Bulk activity reports

Thanks for the info and the hint Dave.

 

While waiting for the functionality to be back again, I think I will give the getActivities method a try.

 

Thanks!

 

--

Salva

All Star

Re: Bulk activity reports

Hi everybody.

 

The getActivities method is working great but I have a strange issue with the getActivity method.

 

The script retrieves the information about all the activities and if there are errors, the getActivity method is used to access the list of errors. When accessing the list of errors to display them on the screen, the email_address tag is empty and the message tag is filled with the e-mail.

 

Here is the code I use to display the information:

 

if ($activity->error_count > 0) {
   $data = $cc->getActivity(ACCESS_TOKEN, $activity->id);
   foreach ($data->errors as $error) {
      print $error->email_address . ": " . $error->message."<br />";
   }
}

 The result of executing this piece of code is as follows:

 

: whatever1@whateverserver1.com
: whatever2@whateverserver2.com
: whatever3@whateverserver3.com

I have also checked the content of the $data variable using a print_r statement and the issue is confirmed, email_address is empty and message stores the e-mail address.

 

Am I doing something wrong or is there a problem with the library?

 

Thanks in advance for the replies.

 

--

Salva

Moderator

Re: Bulk activity reports

Thanks for the feedback, will have someone take a look at this.  It sounds like our mapping of the error array isn't working as expected when it serializes the object.  Will need to have someone look at the raw payload and see how we're doing the mapping and see if we can get a fix out to the Github repo.

Dave Berard
Senior Product Manager, Constant Contact
Moderator

Re: Bulk activity reports

We investigated this, the SDK is actually parsing the response correctly.  However, the response payload we're sending you is definitely not correct.  Can you share your code for how you created the import activity?  We're going to need to attempt to reproduce and dig into this more on our side. 

 

Thanks!

Dave Berard
Senior Product Manager, Constant Contact
All Star

Re: Bulk activity reports

Hi Dave.

 

The process involves two scripts. The first one creates the activities and the second one generates the report.

 

Code of the first script (the one generating the activities):

 

<?php
require_once 'src/Ctct/autoload.php';

use Ctct\ConstantContact;
use Ctct\Components\Contacts\Contact;
use Ctct\Components\Contacts\ContactList;
use Ctct\Components\Contacts\EmailAddress;
use Ctct\Exceptions\CtctException;
use Ctct\Components\Activities\AddContactsImportData;
use Ctct\Components\Activities\AddContacts;

define("APIKEY", "xxxxxxxxxxxxxxxxxxxxxxxx");
define("ACCESS_TOKEN", "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");

$cc = new ConstantContact(APIKEY);

try {
    $activity = $cc->addClearListsActivity(ACCESS_TOKEN, array(0 => 'xx'));

    $connection = mysql_connect("xxxxx.xxxx.xx", "xxxxxxxxxxx", "xxxxxxxxxxxxxxx");
    mysql_select_db("xxxxxxx");
    $result = mysql_query("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
    	
	$contacts = array();
	while ( ($row = mysql_fetch_row($result)) != false) {
		$contact = new AddContactsImportData();
		$contact->addEmail($row[0]);
		$contacts[] = $contact;
	}
	$addContacts = new AddContacts($contacts, array("xx"));
	
	$activity2 = $cc->addCreateContactsActivity(ACCESS_TOKEN, $addContacts);
} catch (CtctException $ex) {
    foreach ($ex->getErrors() as $error) {
        print_r($error);
    }
}
?>

 And here is the code for the second script (the one generating the report):

 

<?php
require_once 'src/Ctct/autoload.php';

use Ctct\ConstantContact;
use Ctct\Components\Contacts\Contact;
use Ctct\Components\Contacts\ContactList;
use Ctct\Components\Contacts\EmailAddress;
use Ctct\Exceptions\CtctException;
use Ctct\Components\Activities\AddContactsImportData;
use Ctct\Components\Activities\AddContacts;

define("APIKEY", "xxxxxxxxxxxxxxxxxxxxxxxx");
define("ACCESS_TOKEN", "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");

$cc = new ConstantContact(APIKEY);

try {
    $activities = $cc->getActivities(ACCESS_TOKEN);
    print "<table>";
    print "<tr><th>Type</th><th width=\"150px;\">Status</th><th>Fecha</th><th width=\"100px\">Contacts</th><th width=\"100px\">Errors</th><th>&nbsp;</th></tr>";
    foreach ($activities as $activity) {
    	print "<tr>
    			<td>".$activity->type."</td>
    			<td>".$activity->status."</td>
    			<td>".$activity->created_date."</td>
    			<td>".$activity->contact_count."</td>
    			<td>".$activity->error_count."</td>";
    	if ($activity->error_count > 0) {
    		$data = $cc->getActivity(ACCESS_TOKEN, $activity->id);
    		print "<td>";
    		foreach ($data->errors as $error) {
    			print $error->email_address . ": " . $error->message."<br />";
    		}
    		print "</td>";
    	} else {
    		print "<td>&nbsp;</td>";
    	}
    		   print "</tr>";
    }
    print "</table>";
} catch (CtctException $ex) {
    foreach ($ex->getErrors() as $error) {
        print_r($error);
    }
}
?>

 

Not sure if this helps, but when the reports could be checked in the ConstantContact web page via Contacts -> Activity, the errors messages were displayed correctly.

 

The scripts are run in a server in the Amazon EC2 cloud with the following configuration:

 

Ubuntu 12.04.3 LTS

Linux 3.2.0-56-virtual #86-Ubuntu SMP Wed Oct 23 18:12:10 UTC 2013 i686 i686 i386 GNU/Linux

Apache/2.2.22 (Ubuntu)

PHP 5.3.10-1ubuntu3.8 with Suhosin-Patch (cli)

Zend Engine v2.3.0

 

If you need any other information, let me know.

 

Thanks for the interest in the case.

 

--

Salva

Moderator

Re: Bulk activity reports

Thanks for sharing, we'll dig into this on our side and try to reproduce the behavior.  It definitely is us returning the wrong information back in the error messages so we need to look into this on our side. 

Dave Berard
Senior Product Manager, Constant Contact
Valued Developer

Re: Bulk activity reports


@On ‎03-11-2014 10:01 AM DaveBerard wrote:

In the new Contacts Management System, we do not currently display the activities created through the API.  The CMS team is aware of this issue and working on a fix.  We hope to have it out in the next 4-8 weeks as we're doing a lot of work around performance.


Any update on this? You hoped it'd be out in 4-8 weeks, it's now been over 22 weeks. 

Honored Contributor

Re: Bulk activity reports

This has been updated for a couple months now in our production environment, and you should be seeing any activities created by API applications visible in the activities page of your Constant Contact account. If you are not seeing your activities appear, please let us know!

 

Best Regards,

Elijah G.
API Support Engineer