我一直在关注mailchimp api,我想知道如何在列表中显示订阅者的实时数量,这可能吗?这个计数器是否可以直播?即,当用户加入时,数字实时增加?
编辑:
我已经习惯了API ......
使用Drewm的mailchimp php包装后,它开始变得更有意义......
我到目前为止
// This is to tell WordPress our file requires Drewm/MailChimp.php.
require_once( 'src/Drewm/MailChimp.php' );
// This is for namespacing since Drew used that.
use \Drewm;
// Your Mailchimp API Key
$api = 'APIKEY';
$id = 'LISTID';
// Initializing the $MailChimp object
$MailChimp = new \Drewm\MailChimp($api);
$member_info = $MailChimp->call('lists/members', array(
'apikey' => $api,
'id' => $id // your mailchimp list id here
)
);
但不确定如何显示这些值,它目前只是在说'数组'当我回复$ member_info时,这可能完全是因为我对PHP的无知。对s的任何建议
答案 0 :(得分:0)
我知道这可能很旧,但这也许会帮助其他人寻找。最新版本的API和PHP文件。
use \DrewM\MailChimp\MailChimp;
$MailChimp = new MailChimp($api_key);
$data = $MailChimp->get('lists');
print_r($data);// view output
$total_members = $data['lists'][0]['stats']['member_count'];
$list_id = $data['lists'][0]['id'];
$ data ['lists'] [0] =第一个列表。如果您有更多,那就像$ data ['lists'] [1]等等...
并从列表中获取成员列表:
$data = $MailChimp->get("lists/$list_id/members");
print_r($data['members']);// view output
foreach($data['members'] as $member){
$email = $member['email_address'];
$added = date('Y/m/d',strtotime($member['timestamp_opt']));
// I use reverse dates for sorting in a *datatable* so it properly sorts by date
}
您可以查看 print_r 输出以获取想要的内容。