« Back to Documentation Overview

campaignSendNow – v1.1

 campaignSendNow(string apikey, string cid)

Send a given campaign immediately

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 send
Returns
boolean true on success

Examples (2)

download example code

[1] mcapi_campaignSendNow.php

  1. <?php
  2. /**
  3. This Example shows how to immediately send a Campaign 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->campaignSendNow($campaignId);
  11.  
  12. if ($api->errorCode){
  13. echo "Unable to Send Campaign!";
  14. echo "\n\tCode=".$api->errorCode;
  15. echo "\n\tMsg=".$api->errorMessage."\n";
  16. } else {
  17. echo "Campaign Sent!\n";
  18. }
  19.  

[2] xml-rpc_campaignSendNow.php

  1. <?php
  2. /**
  3. This Example shows how to immediately Send a prepared Campaign using XML-RPC.
  4. Note that we are using the PEAR XML-RPC 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->campaignSendNow($apikey, $campaignId);
  12. echo "SUCCESS! \n";
  13. echo "Returned: ".$result."\n";
  14. } catch (XML_RPC2_FaultException $e){
  15. echo "ERROR!!!!\n";
  16. echo $e->getFaultCode()." : ".$e->getFaultString()."\n";
  17. }
  18. ?>
  19.