« Back to Documentation Overview

campaignUpdate – v1.1

 campaignUpdate(string apikey, string cid, string name, mixed value)

Update just about any setting for a campaign that has not been sent. See campaignCreate() for details

Caveats:

  • If you set list_id, all segmentation options will be deleted and must be re-added.
  • If you set template_id, you need to follow that up by setting it's 'content'
  • If you set segment_opts, you should have tested your options against campaignSegmentTest() as campaignUpdate() will not allow you to set a segment that includes no members.

Section
Campaign Related
Parameters
apikey a valid API Key for your user account. Get by calling Get by visiting your API dashboard
cid the Campaign Id to update
name the parameter name ( see campaignCreate() )
value an appropriate value for the parameter ( see campaignCreate() )
Returns
boolean true if the update succeeds, otherwise an error will be thrown

Examples (4)

download example code

[1] mcapi_campaignUpdate.php

  1. <?php
  2. /**
  3. This Example shows how to Update a regular 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. $field = "title";
  11. $value = "My New Title";
  12.  
  13. $retval = $api->campaignUpdate($campaignId, $field, $value);
  14.  
  15. if ($api->errorCode){
  16. echo "Unable to Update Campaign!";
  17. echo "\n\tCode=".$api->errorCode;
  18. echo "\n\tMsg=".$api->errorMessage."\n";
  19. } else {
  20. echo "SUCCESS! \n";
  21. }
  22.  

[2] mcapi_campaignUpdateAB.php

  1. <?php
  2. /**
  3. This Example shows how to Update an A/B Split 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. $field = "absplit";
  11. $value = "My New Title";
  12.  
  13. $ab_opts = array();
  14. $ab_opts['split_test'] = 'from_name';
  15. $ab_opts['pick_winner'] = 'manual';
  16. $ab_opts['from_name_a'] = 'David Gilmour';
  17. $ab_opts['from_email_a'] = 'david@example.org';
  18. $ab_opts['from_name_b'] = 'Roger Waters';
  19. $ab_opts['from_email_b'] = 'roger@example.org';
  20.  
  21. $retval = $api->campaignUpdate($campaignId, $field, $ab_opts);
  22.  
  23. if ($api->errorCode){
  24. echo "Unable to Update Campaign!";
  25. echo "\n\tCode=".$api->errorCode;
  26. echo "\n\tMsg=".$api->errorMessage."\n";
  27. } else {
  28. echo "SUCCESS!\n";
  29. }
  30.  

[3] xml-rpc_campaignUpdate.php

  1. <?php
  2. /**
  3. This Example shows how to update various parameters of a 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. $field = "title";
  12. $value = "My New Title";
  13.  
  14. $result = $client->campaignUpdate($apikey, $campaignId, $field, $value);
  15. echo "SUCCESS! \n";
  16. echo "Returned: ".$result;
  17. } catch (XML_RPC2_FaultException $e){
  18. echo "ERROR!!!!\n";
  19. echo $e->getFaultCode()." : ".$e->getFaultString()."\n";
  20. }
  21.  

[4] xml-rpc_campaignUpdateAB.php

  1. <?php
  2. /**
  3. This Example shows how to update an AB Split 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. $field = "absplit";
  12. $value = "My New Title";
  13.  
  14. $ab_opts = array();
  15. $ab_opts['split_test'] = 'from_name';
  16. $ab_opts['pick_winner'] = 'manual';
  17. $ab_opts['from_name_a'] = 'David Gilmour';
  18. $ab_opts['from_email_a'] = 'david@example.org';
  19. $ab_opts['from_name_b'] = 'Roger Waters';
  20. $ab_opts['from_email_b'] = 'roger@example.org';
  21.  
  22. $result = $client->campaignUpdate($apikey, $campaignId, $field, $ab_opts);
  23.  
  24. echo "SUCCESS! \n";
  25. echo "Returned: ".$result;
  26. } catch (XML_RPC2_FaultException $e){
  27. echo "ERROR!!!!\n";
  28. echo $e->getFaultCode()." : ".$e->getFaultString()."\n";
  29. }
  30.