« Back to Documentation Overview

campaigns – v1.1

 campaigns(string apikey, string filter_id, integer filter_folder, string filter_fromname, string filter_fromemail, string filter_title, string filter_subject, string filter_sendtimestart, string filter_sendtimeend, boolean filter_exact, 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 calling Get by visiting your API dashboard
filter_id optional - only show campaigns from this list id - get lists using lists()
filter_folder optional - only show campaigns from this folder id - get folders using campaignFolders()
filter_fromname optional - only show campaigns that have this "From Name"
filter_fromemail optional - only show campaigns that have this "Reply-to Email"
filter_title optional - only show campaigns that have this title
filter_subject optional - only show campaigns that have this subject
filter_sendtimestart optional - only show campaigns that have been sent since this date/time - format is YYYY-MM-DD HH:mm:ss (24hr)
filter_sendtimeend optional - only show campaigns that have been sent before this date/time - format is YYYY-MM-DD HH:mm:ss (24hr)
filter_exact optional - flag for whether to filter on exact values when filtering, or search within content for filter values
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=5000)
Returns
array list of campaigns and their associated information (see Returned Fields for description)
Returned Fields
stringidCampaign Id (used for all other campaign functions)
stringweb_idThe Campaign id used in our web app, allows you to create a link directly to it
stringlist_idThe List used for this campaign
stringfolder_idThe Folder this campaign is in
stringtitleTitle of the campaign
stringtypeThe type of campaign this is (regular,plaintext,absplit,rss,inspection,auto)
datecreate_timeCreation time for the campaign
datesend_timeSend time for the campaign
integeremails_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_emailCustom "To:" email string using merge variables
stringarchive_urlArchive link for the given campaign
booleaninline_cssWhether or not the campaigns content auto-css-lined

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.