« Back to Documentation Overview

campaigns – v1.3

 campaigns(string apikey, array filters, int start, int limit)

Get the list of campaigns and their details matching the specified filters

Section
Campaign Related
Parameters
apikey a valid API Key for your user account. Get by visiting your API dashboard
filters a hash of filters to apply to this query - all are optional:
stringcampaign_idoptional - return the campaign using a know campaign_id. Accepts multiples separated by commas when not using exact matching.
stringlist_idoptional - the list to send this campaign to- get lists using lists(). Accepts multiples separated by commas when not using exact matching.
intfolder_idoptional - only show campaigns from this folder id - get folders using campaignFolders(). Accepts multiples separated by commas when not using exact matching.
inttemplate_idoptional - only show campaigns using this template id - get templates using templates(). Accepts multiples separated by commas when not using exact matching.
stringstatusoptional - return campaigns of a specific status - one of "sent", "save", "paused", "schedule", "sending". Accepts multiples separated by commas when not using exact matching.
stringtypeoptional - return campaigns of a specific type - one of "regular", "plaintext", "absplit", "rss", "auto". Accepts multiples separated by commas when not using exact matching.
stringfrom_nameoptional - only show campaigns that have this "From Name"
stringfrom_emailoptional - only show campaigns that have this "Reply-to Email"
stringtitleoptional - only show campaigns that have this title
stringsubjectoptional - only show campaigns that have this subject
stringsendtime_startoptional - only show campaigns that have been sent since this date/time (in GMT) - format is YYYY-MM-DD HH:mm:ss (24hr)
stringsendtime_endoptional - only show campaigns that have been sent before this date/time (in GMT) - format is YYYY-MM-DD HH:mm:ss (24hr)
booleanexactoptional - flag for whether to filter on exact values when filtering, or search within content for filter values - defaults to true. Using this disables the use of any filters that accept multiples.
start optional - control paging of campaigns, start results at this campaign #, defaults to 1st page of data (page 0)
limit optional - control paging of campaigns, number of campaigns to return with each call, defaults to 25 (max=1000)
Returns
array an array containing a count of all matching campaigns and the specific ones for the current page (see Returned Fields for description)
inttotalthe total number of campaigns matching the filters passed in
arraydatathe data for each campaign being returned
stringidCampaign Id (used for all other campaign functions)
intweb_idThe Campaign id used in our web app, allows you to create a link directly to it
stringlist_idThe List used for this campaign
intfolder_idThe Folder this campaign is in
inttemplate_idThe Template this campaign uses
stringcontent_typeHow the campaign's content is put together - one of 'template', 'html', 'url'
stringtitleTitle of the campaign
stringtypeThe type of campaign this is (regular,plaintext,absplit,rss,inspection,auto)
stringcreate_timeCreation time for the campaign
stringsend_timeSend time for the campaign - also the scheduled time for scheduled campaigns.
intemails_sentNumber of emails email was sent to
stringstatusStatus of the given campaign (save,paused,schedule,sending,sent)
stringfrom_nameFrom name of the given campaign
stringfrom_emailReply-to email of the given campaign
stringsubjectSubject of the given campaign
stringto_nameCustom "To:" email string using merge variables
stringarchive_urlArchive link for the given campaign
booleaninline_cssWhether or not the campaign content's css was auto-inlined
stringanalyticsEither "google" if enabled or "N" if disabled
stringanalytics_tagThe name/tag the campaign's links were tagged with if analytics were enabled.
booleanauthenticateWhether or not the campaign was authenticated
booleanecomm360Whether or not ecomm360 tracking was appended to links
booleanauto_tweetWhether or not the campaign was auto tweeted after sending
stringauto_fb_postA comma delimited list of Facebook Profile/Page Ids the campaign was posted to after sending. If not used, blank.
booleanauto_footerWhether or not the auto_footer was manually turned on
booleantimewarpWhether or not the campaign used Timewarp
stringtimewarp_scheduleThe time, in GMT, that the Timewarp campaign is being sent. For A/B Split campaigns, this is blank and is instead in their schedule_a and schedule_b in the type_opts array
arraytrackingthe various tracking options used
booleanhtml_clickswhether or not tracking for html clicks was enabled.
booleantext_clickswhether or not tracking for text clicks was enabled.
booleanopenswhether or not opens tracking was enabled.
stringsegment_texta string marked-up with HTML explaining the segment used for the campaign in plain English
arraysegment_optsthe segment used for the campaign - can be passed to campaignSegmentTest() or campaignCreate()
arraytype_optsthe type-specific options for the campaign - can be passed to campaignCreate()

Examples (2)

download example code

[1] mcapi_campaigns.php

  1. <?php
  2. /**
  3. This Example shows how to retrieve a list of your campaigns via the MCAPI class.
  4. **/
  5. require_once 'inc/MCAPI.class.php';
  6. require_once 'inc/config.inc.php'; //contains apikey
  7.  
  8. $api = new MCAPI($apikey);
  9.  
  10. $retval = $api->campaigns();
  11.  
  12. if ($api->errorCode){
  13. echo "Unable to Pull list of Campaign!";
  14. echo "\n\tCode=".$api->errorCode;
  15. echo "\n\tMsg=".$api->errorMessage."\n";
  16. } else {
  17. echo sizeof($retval['total'])." Total Campaigns Matched.\n";
  18. echo sizeof($retval['data'])." Total Campaigns returned:\n";
  19. foreach($retval['data'] as $c){
  20. echo "Campaign Id: ".$c['id']." - ".$c['title']."\n";
  21. echo "\tStatus: ".$c['status']." - type = ".$c['type']."\n";
  22. echo "\tsent: ".$c['send_time']." to ".$c['emails_sent']." members\n";
  23. }
  24. }
  25.  
  26. ?>
  27.  

[2] xml-rpc_campaigns.php

  1. <?php
  2. /**
  3. This Example shows how to pull a list of Campaigns on your account using XML-RPC
  4. Note that we are using the PEAR XML-RPC2 client and recommend others do as well.
  5. **/
  6. require_once 'XML/RPC2/Client.php';
  7. require_once 'inc/config.inc.php';
  8. try {
  9. $client = XML_RPC2_Client::create($apiUrl);
  10.  
  11. $result = $client->campaigns($apikey);
  12. echo sizeof($result['total'])." Total Campaigns Matched.\n";
  13. echo sizeof($result['data'])." Campaigns returned:\n";
  14. foreach($result['data'] as $c){
  15. echo "Campaign Id: ".$c['id']." - ".$c['title']."\n";
  16. echo "\tStatus: ".$c['status']." - type = ".$c['type']."\n";
  17. echo "\tsent: ".$c['send_time']." to ".$c['emails_sent']." members\n";
  18. }
  19. } catch (XML_RPC2_FaultException $e){
  20. echo "ERROR!!!!\n";
  21. echo $e->getFaultCode()." : ".$e->getFaultString()."\n";
  22. }
  23.  
  24. ?>
  25.