« Back to Documentation OverviewcampaignAdvice – v1.2
campaignAdvice(string apikey, string cid)
Retrieve the text presented in our app for how a campaign performed and any advice we may have for you - best
suited for display in customized reports pages. Note: some messages will contain HTML - clean tags as necessary
| Parameters | mcapi_campaignAdvice.php| apikey | a valid API Key for your user account. Get by visiting your API dashboard |
| cid | the campaign id to pull advice text for (can be gathered using campaigns()) |
| Returns | | array |
advice on the campaign's performance |
| Returned Fields | msg | the | advice message | type | the | "type" of the message. one of: negative, positive, or neutral |
Examples (1)
download example code
[1] mcapi_campaignAdvice.php
<?php
/**
This Example shows how to retrieve campaign Advice messages from the API with
some basic error checking.
**/
// Include the MailChimp API code. Do Not Edit This!
require_once 'inc/MCAPI.class.php';
require_once 'inc/config.inc.php'; //contains apikey
// Connect to the MailChimp server with the user's credentials.
$api = new MCAPI($apikey);
$advice = $api->campaignAdvice($campaignId);
if ($api->errorCode){
echo "\tCode=".$api->errorCode."\n"; echo "\tMsg=".$api->errorMessage."\n"; } else {
foreach($advice as $adv){
echo "Type: ".$adv['type']."\n"; echo "Message: ".$adv['msg']."\n"; }
} else {
echo "Sorry, no advice for this campaign!\n"; }
}
?>