Back to Documentation Overview

campaigns

public static campaigns(string apikey, array filters, integer start, integer 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 a single campaign using a know campaign_id
stringlist_idoptional - the list to send this campaign to- get lists using lists()
integerfolder_idoptional - only show campaigns from this folder id - get folders using campaignFolders()
stringstatusoptional - return campaigns of a specific status - one of "sent", "save", "paused", "schedule", "sending"
stringtypeoptional - return campaigns of a specific type - one of "regular", "plaintext", "absplit", "rss", "trans", "auto"
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
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   -  list of campaigns and their associated information (see Returned Fields for description)
Returned Fields:
string id Campaign Id (used for all other campaign functions)
integer web_id The Campaign id used in our web app, allows you to create a link directly to it
string title Title of the campaign
string type The type of campaign this is (regular,plaintext,absplit,rss,inspection,trans,auto)
date create_time Creation time for the campaign
date send_time Send time for the campaign - also the scheduled time for scheduled campaigns.
integer emails_sent Number of emails email was sent to
string status Status of the given campaign (save,paused,schedule,sending,sent)
string from_name From name of the given campaign
string from_email Reply-to email of the given campaign
string subject Subject of the given campaign
string to_email Custom "To:" email string using merge variables
string archive_url Archive link for the given campaign
boolean inline_css Whether or not the campaigns content auto-css-lined
string analytics Either "google" if enabled or "N" if disabled
string analytics_tag The name/tag the campaign's links were tagged with if analytics were enabled.
boolean track_clicks_text Whether or not links in the text version of the campaign were tracked
boolean track_clicks_html Whether or not links in the html version of the campaign were tracked
boolean track_opens Whether or not opens for the campaign were tracked
string segment_text a string marked-up with HTML explaining the segment used for the campaign in plain English
array segment_opts the segment used for the campaign - can be passed to campaignSegmentTest() or 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)." Campaigns Returned:\n";
  18. foreach($retval as $c){
  19. echo "Campaign Id: ".$c['id']." - ".$c['title']."\n";
  20. echo "\tStatus: ".$c['status']." - type = ".$c['type']."\n";
  21. echo "\tsent: ".$c['send_time']." to ".$c['emails_sent']." members\n";
  22. }
  23. }
  24.  

[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 "SUCCESS! \n";
  13. foreach($result as $c){
  14. echo "Campaign Id: ".$c['id']." - ".$c['title']."\n";
  15. echo "\tStatus: ".$c['status']." - type = ".$c['type']."\n";
  16. echo "\tsent: ".$c['send_time']." to ".$c['emails_sent']." members\n";
  17. }
  18. } catch (XML_RPC2_FaultException $e){
  19. echo "ERROR!!!!\n";
  20. echo $e->getFaultCode()." : ".$e->getFaultString()."\n";
  21. }
  22.  
  23.  
Add New Note User Contributed Notes for campaigns
No notes, yet... Will you be the first??