AccountActivity is used to retrieve a file containing all of the activity data for a single day for an activity type. If you need to retrieve your data more frequently that once a day, you should considering using the “Event Feed” which will allow you to consume the same activity/events as they occur. This API differs from others in that it “streams” back a large binary byte array. It can be invoked via using utilities like WGET or CURL, or you can write your code to retrieve the data. It’s important to remember that these files can be large and often will be too large to fit into memory all at once. Write your code so that the file is streamed to disk or to a database for processing.
XSD Location
For a detailed list of all response values, refer to the XSD file below.
v3.0 (unchanged in 3.1)
Input Parameters
Parameter | Description |
Action | AccountActivity |
AccountId | The MessageGears account id to which this item belongs. |
ApiKey | A secret key only known by you. Keep this key confidential. |
ActivityDate | The date of the activity that is being requested. This field must be in the form of yyyy-MM-dd (example: 2010-12-31). |
ActivityType | One of the following strings must be provided: OPENS, CLICKS, BOUNCES, DELIVERIES, SPAM_COMPLAINTS, RENDER_ERRORS, UNSUBSCRIBES, JOB_ERRORS, MOBILE_PUSH_DELIVERIES, MOBILE_PUSH_CLICKS, MOBILE_PUSH_DELIVERY_FAILURES, MOBILE_PUSH_RENDER_ERRORS, SMS_CLICKS, SMS_DELIVERIES, SMS_DELIVERY_FAILURES, SMS_RENDER_ERRORS, SMS_INBOUNDS |
UseCompression | Set whether the data returned is compressed in .zip format. Set to TRUE to download the data in a compressed format (this is the suggested method) |
Response Values
Element Name | Description |
ActivityItems | The root element of the XML response. |
RequestId | The MessageGears request id of the job of which the activity items belongs. |
CorrelationId | The correlation id provided with the invocation of this job, if supplied. This field allows you to supply your own job id. This ID is designed to make it easier to match events coming out of MessageGears with the job they belong to in your own system. |
ActivityId | The unique activity id for an individual activity item. |
Timestamp | The time that the event/activity item occurred. |
EmailAddress | The email address of the recipient responsible for the activity item. |
IpAddress | The ip address that generated the activity. |
Programming Examples
REST
Request
https://api.messagegears.net/3.1/WebService
?Action=AccountActivity
&AccountId=123456789
&ApiKey=8bb6118f8fd6935ad0876a3be34a717d32708ffd
&ActivityDate=2010-12-31
&ActivityType=BOUNCES
See above for examples of each response by ActivityType
Java SDK
package com.messagegears.sdk.examples;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Calendar;
import java.util.Date;
import com.messagegears.sdk.v3_1.BouncedMessageActivity;
import com.messagegears.sdk.v3_1.ClickActivity;
import com.messagegears.sdk.v3_1.DeliveredMessageActivity;
import com.messagegears.sdk.v3_1.JobErrorActivity;
import com.messagegears.sdk.v3_1.OpenActivity;
import com.messagegears.sdk.v3_1.RenderErrorActivity;
import com.messagegears.sdk.v3_1.SpamComplaintActivity;
import com.messagegears.sdk.v3_1.UnsubActivity;
import com.messagegears.sdk.MessageGearsClient;
import com.messagegears.sdk.MessageGearsListener;
import com.messagegears.sdk.MessageGearsProperties;
import com.messagegears.sdk.activity.MessageGearsActivityFileProcessor;
import com.messagegears.sdk.model.ActivityType;
import com.messagegears.sdk.model.request.AccountActivityRequest;
import com.messagegears.sdk.output.ScreenWriter;
public class ActivityFileExample implements MessageGearsListener {
public static final String MY_MESSAGEGEARS_ACCOUNT_ID = "your MessageGears Account Id";
public static final String MY_MESSAGEGEARS_API_KEY = "your MessageGears API Key";
public static Date activityDate;
public static void main (String[] args)
{
// Create the AWS properties object
MessageGearsProperties props = new MessageGearsProperties();
props.setMyMessageGearsAccountId(MY_MESSAGEGEARS_ACCOUNT_ID);
props.setMyMessageGearsApiKey(MY_MESSAGEGEARS_API_KEY);
// Create the main client object
MessageGearsClient client = new MessageGearsClient(props);
// Create an object of this listener class and process
ActivityFileExample listener = new ActivityFileExample();
// Create a file processor object, and request processing
MessageGearsActivityFileProcessor processor = new MessageGearsActivityFileProcessor(listener);
// Set date to yesterday.
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_YEAR, -1);
activityDate = calendar.getTime();
AccountActivityRequest request = new AccountActivityRequest();
request.setDate(activityDate);
// Download the activity files and process them.
for (ActivityType activityType : ActivityType.values()) {
try {
request.setActivityType(activityType);
String downloadedFileName = client.accountActivity(request);
FileInputStream inputStream = new FileInputStream(new File(downloadedFileName));
processor.process(inputStream, activityType);
} catch (FileNotFoundException fnfe) {
System.err.println("Error processing activity of type: " + activityType.name());
System.err.println("FileNotFoundException: " + fnfe.getMessage());
}
}
}
public void onOpen(OpenActivity activity) {
ScreenWriter.print(activity);
}
public void onClick(ClickActivity activity) {
ScreenWriter.print(activity);
}
public void onBounce(BouncedMessageActivity activity) {
ScreenWriter.print(activity);
}
public void onDelivery(DeliveredMessageActivity activity) {
ScreenWriter.print(activity);
}
public void onSpamComplaint(SpamComplaintActivity activity) {
ScreenWriter.print(activity);
}
public void onJobError(JobErrorActivity activity) {
ScreenWriter.print(activity);
}
public void onRenderError(RenderErrorActivity activity) {
ScreenWriter.print(activity);
}
public void onUnsub(UnsubActivity activity) {
ScreenWriter.print(activity);
}
}
C# SDK
using System;
using MessageGears;
using MessageGears.Model;
using MessageGears.Model.Generated;
namespace MessageGears.Examples
{
public class ActivityFileExample : MessageGearsListener
{
public const String MY_MESSAGEGEARS_ACCOUNT_ID = "your MessageGears Account Id";
public const String MY_MESSAGEGEARS_API_KEY = "your MessageGears API Key";
public static DateTime activityDate = System.DateTime.Today.AddDays(-1);
public static void Main ()
{
// Create the AWS properties object
MessageGearsProperties props = new MessageGearsProperties();
props.MyMessageGearsAccountId = MY_MESSAGEGEARS_ACCOUNT_ID;
props.MyMessageGearsApiKey = MY_MESSAGEGEARS_API_KEY;
// Create the main client object
MessageGearsClient client = new MessageGearsClient(props);
// Create an object of this listener class and process
ActivityFileExample listener = new ActivityFileExample();
// Create a file processor object, and request processing
MessageGearsActivityFileProcessor processor = new MessageGearsActivityFileProcessor(listener);
// Download the activity files and process them.
processor.process(client.AccountActivity(activityDate, ActivityType.BOUNCES));
processor.process(client.AccountActivity(activityDate, ActivityType.CLICKS));
processor.process(client.AccountActivity(activityDate, ActivityType.DELIVERIES));
processor.process(client.AccountActivity(activityDate, ActivityType.JOB_ERRORS));
processor.process(client.AccountActivity(activityDate, ActivityType.OPENS));
processor.process(client.AccountActivity(activityDate, ActivityType.RENDER_ERRORS));
processor.process(client.AccountActivity(activityDate, ActivityType.SPAM_COMPLAINTS));
processor.process(client.AccountActivity(activityDate, ActivityType.UNSUBSCRIBES));
}
public void OnOpen(OpenActivity activity)
{
Console.WriteLine("***** Open Event Received");
}
public void OnClick(ClickActivity activity)
{
Console.WriteLine("***** Click Event Received: " + activity.ActivityId);
}
public void OnBounce(BouncedMessageActivity activity)
{
Console.WriteLine("***** Bounce Event Received");
}
public void OnDelivery(DeliveredMessageActivity activity)
{
Console.WriteLine("***** Delivery Event Received");
}
public void OnSpamComplaint(SpamComplaintActivity activity)
{
Console.WriteLine("***** Spam Complaint Event Received");
}
public void OnJobError(JobErrorActivity activity)
{
Console.WriteLine("***** Job Error Event Received");
}
public void OnRenderError(RenderErrorActivity activity)
{
Console.WriteLine("***** Render Error Event Received");
}
public void OnUnsub(UnsubActivity activity)
{
Console.WriteLine("***** Unsub Event Received");
}
}
}
Comments
Article is closed for comments.