« Back to Documentation Overview

campaignSchedule – v1.1

 campaignSchedule(string apikey, string cid, string schedule_time, string schedule_time_b)

Schedule a campaign to be sent in the future

Section
Campaign Related
Parameters
apikey a valid API Key for your user account. Get by calling Get by visiting your API dashboard
cid the id of the campaign to schedule
schedule_time the time to schedule the campaign. For A/B Split "schedule" campaigns, the time for Group A - in YYYY-MM-DD HH:II:SS format in GMT
schedule_time_b optional - the time to schedule Group B of an A/B Split "schedule" campaign - in YYYY-MM-DD HH:II:SS format in GMT
Returns
boolean true on success

Examples (2)

download example code

[1] mcapi_campaignSchedule.php

  1. <?php
  2. /**
  3. This Example shows how to schedule a campaign for future delivery
  4. via the MCAPI class.
  5. **/
  6. require_once 'inc/MCAPI.class.php';
  7. require_once 'inc/config.inc.php'; //contains apikey
  8.  
  9. $api = new MCAPI($apikey);
  10.  
  11. $schedule_for = '2018-04-01 09:05:21';
  12. $retval = $api->campaignSchedule($campaignId, $schedule_for);
  13.  
  14. if ($api->errorCode){
  15. echo "Unable to Schedule Campaign!";
  16. echo "\n\tCode=".$api->errorCode;
  17. echo "\n\tMsg=".$api->errorMessage."\n";
  18. } else {
  19. echo "Campaign Scheduled to be delivered $schedule_for!\n";
  20. }
  21.  

[2] xml-rpc_campaignSchedule.php

  1. <?php
  2. /**
  3. This Example shows how to Schedule a Campaign to be sent at a specified time in the
  4. future using the XML-RPC service and do some basic error checking.
  5. Note that we are using the PEAR XML-RPC client and recommend others do as well.
  6. **/
  7. require_once 'XML/RPC2/Client.php';
  8. require_once 'inc/config.inc.php';
  9. try {
  10. $client = XML_RPC2_Client::create($apiUrl);
  11.  
  12. // note that the Schedule date MUST be formatted like this:
  13. // '2008-04-01 09:05:21' means 'April 1st, 2008'
  14. $schedule_for = '2018-04-01 09:05:21';
  15. $result = $client->campaignSchedule($apikey, $campaignId, $schedule_for);
  16. echo "SUCCESS!\n";
  17. var_dump($result);
  18. } catch (XML_RPC2_FaultException $e){
  19. echo "ERROR!!!!\n";
  20. echo $e->getFaultCode()." : ".$e->getFaultString()."\n";
  21. }
  22. ?>
  23.