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:
| Section | Campaign Related |
|---|
| Parameters | |
|---|---|
| apikey | a valid API Key for your user account. Get by visiting your API dashboard |
| cid | the Campaign Id to update |
| name | the parameter name ( see campaignCreate() ). For items in the options array, this will be that parameter's name (subject, from_email, etc.). Additional parameters will be that option name (content, segment_opts). "type_opts" will be the name of the type - rss, auto, trans, etc. |
| value | an appropriate value for the parameter ( see campaignCreate() ). For items in the options array, this will be that parameter's value. For additional parameters, this is the same value passed to them. |
| Returns | |
|---|---|
| boolean | true if the update succeeds, otherwise an error will be thrown |
[1] mcapi_campaignUpdate.php
<?php /** This Example shows how to Update a regular Campaign via the MCAPI class. **/ require_once 'inc/MCAPI.class.php'; require_once 'inc/config.inc.php'; //contains apikey $field = "title"; $value = "My New Title"; $retval = $api->campaignUpdate($campaignId, $field, $value); if ($api->errorCode){ } else { } ?>
[2] mcapi_campaignUpdateAB.php
<?php /** This Example shows how to Update an A/B Split Campaign via the MCAPI class. **/ require_once 'inc/MCAPI.class.php'; require_once 'inc/config.inc.php'; //contains apikey $field = "absplit"; $value = "My New Title"; $ab_opts['split_test'] = 'from_name'; $ab_opts['pick_winner'] = 'manual'; $ab_opts['from_name_a'] = 'David Gilmour'; $ab_opts['from_email_a'] = 'david@example.org'; $ab_opts['from_name_b'] = 'Roger Waters'; $ab_opts['from_email_b'] = 'roger@example.org'; $retval = $api->campaignUpdate($campaignId, $field, $ab_opts); if ($api->errorCode){ } else { } ?>
[3] xml-rpc_campaignUpdate.php
<?php /** This Example shows how to update various parameters of a Campaign using XML-RPC. Note that we are using the PEAR XML-RPC client and recommend others do as well. **/ require_once 'XML/RPC2/Client.php'; require_once 'inc/config.inc.php'; try { $field = "title"; $value = "My New Title"; $result = $client->campaignUpdate($apikey, $campaignId, $field, $value); } catch (XML_RPC2_FaultException $e){ } ?>
[4] xml-rpc_campaignUpdateAB.php
<?php /** This Example shows how to update an AB Split Campaign using XML-RPC. Note that we are using the PEAR XML-RPC client and recommend others do as well. **/ require_once 'XML/RPC2/Client.php'; require_once 'inc/config.inc.php'; try { $field = "absplit"; $value = "My New Title"; $ab_opts['split_test'] = 'from_name'; $ab_opts['pick_winner'] = 'manual'; $ab_opts['from_name_a'] = 'David Gilmour'; $ab_opts['from_email_a'] = 'david@example.org'; $ab_opts['from_name_b'] = 'Roger Waters'; $ab_opts['from_email_b'] = 'roger@example.org'; $result = $client->campaignUpdate($apikey, $campaignId, $field, $ab_opts); } catch (XML_RPC2_FaultException $e){ } ?>