Display total number of subscribers to a list

Hi

Well this is my first post on this forum... I'm a web designer, doing lots of Wp sites, and I'd like to state that I'm not used to working with APIs so please be gentle :)

A client has asked me to display the total amount of subscribers to his newsletter on the frontend of his site.

This should be similar to a feedburner's subscriber's stats...

But... I need help as I have no idea how to go about this. I have found a forum thread that deals with the same issue, but I can't understand the OP's code: http://www.campaignmonitor.com/forums/viewtopic.php?id=4543

Would anyone be kind enough to guide me in the right direction?

Thanks in advance

Max

jamesd jamesd, 5 years ago

Hey Max,

I'd suggest getting the PHP API library and using the list stats example as a guide:

<?php

require_once '../../csrest_lists.php';

$wrap = new CS_REST_Lists('List ID', 'Your API Key');

$result = $wrap->get_stats();

echo "Result of GET /api/v3/lists/{ID}/stats\n<br />";
if($result->was_successful()) {
    echo "Got list stats\n<br /><pre>";
    var_dump($result->response);
} else {
    echo 'Failed with code '.$result->http_status_code."\n<br /><pre>";
    var_dump($result->response);
}
echo '</pre>';

The output of getting stats for a list includes TotalActiveSubscribers, as shown in the documentation:

{
  "TotalActiveSubscribers": 6,
  "NewActiveSubscribersToday": 0,
  "NewActiveSubscribersYesterday": 8,
  "NewActiveSubscribersThisWeek": 8,
  "NewActiveSubscribersThisMonth": 8,
  "NewActiveSubscribersThisYear": 8,
  "TotalUnsubscribes": 2,
  "UnsubscribesToday": 0,
  "UnsubscribesYesterday": 2,
  "UnsubscribesThisWeek": 2,
  "UnsubscribesThisMonth": 2,
  "UnsubscribesThisYear": 2,
  "TotalDeleted": 0,
  "DeletedToday": 0,
  "DeletedYesterday": 0,
  "DeletedThisWeek": 0,
  "DeletedThisMonth": 0,
  "DeletedThisYear": 0,
  "TotalBounces": 0,
  "BouncesToday": 0,
  "BouncesYesterday": 0,
  "BouncesThisWeek": 0,
  "BouncesThisMonth": 0,
  "BouncesThisYear": 0
}
Maxg, 5 years ago

Wow! Thank you - I'm actually hiring a php dev to help me do that - your info will be very useful;

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free
1-888-533-8098