« Back to Documentation Overview

campaignAdvice – 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

Section
Campaign Stats
mcapi_campaignAdvice.php
Parameters
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
msgtheadvice message
typethe"type" of the message. one of: negative, positive, or neutral

Examples (1)

download example code

[1] mcapi_campaignAdvice.php

  1. <?php
  2. /**
  3. This Example shows how to retrieve campaign Advice messages from the API with
  4. some basic error checking.
  5. **/
  6.  
  7. // Include the MailChimp API code. Do Not Edit This!
  8. require_once 'inc/MCAPI.class.php';
  9. require_once 'inc/config.inc.php'; //contains apikey
  10.  
  11. // Connect to the MailChimp server with the user's credentials.
  12. $api = new MCAPI($apikey);
  13.  
  14. $advice = $api->campaignAdvice($campaignId);
  15.  
  16. if ($api->errorCode){
  17. echo "Unable to run campaignAdvice()!\n";
  18. echo "\tCode=".$api->errorCode."\n";
  19. echo "\tMsg=".$api->errorMessage."\n";
  20. } else {
  21. if (sizeof($advice)>0){
  22. foreach($advice as $adv){
  23. echo "Type: ".$adv['type']."\n";
  24. echo "Message: ".$adv['msg']."\n";
  25. }
  26. } else {
  27. echo "Sorry, no advice for this campaign!\n";
  28. }
  29. }
  30.  
  31. ?>
  32.  
  33.