Mailchimp API 2.0使用listSubscribe()多次

时间:2015-08-20 18:08:03

标签: wordpress mailchimp shopp

我正在为基于WordPress的网站上的客户端集成Shopp和Mailchimp。结帐页面包含多个电子邮件地址的输入,所有这些都应通过API添加到MailChimp。我在使用MCAPI.php包装器获取第一封电子邮件时,使用listSubscribe()取得了成功。 listSubscribe()是否可以在处理checkout时运行的同一PHP函数中重用?

这是我目前的代码:

/* include MailChimp API on checkout init */
add_action('shopp_order_success', 'opc_mc_checkout');
function opc_mc_checkout () {
// do stuff
require_once 'MCAPI.class.php';
$apikey='redacted'; // Enter your API key
$api = new MCAPI($apikey);
$retval = $api->lists();
$listid='redacted'; // Enter list Id here
$email=shopp('purchase.email', 'return=true'); // Enter subscriber email address
$name=shopp('purchase.firstname', 'return=true'); // Enter subscriber first name
$lname=shopp('purchase.lastname', 'return=true'); // Enter subscriber last name

// By default this sends a confirmation email - you will not see new members
// until the link contained in it is clicked!

$merge_vars = array('FNAME' => $name, 'LNAME' => $lname);
if($api->listSubscribe($listid, $email,$merge_vars) === true) {
}

/* teacher extra emails */
$apikey='redacted'; // Enter your API key
$api = new MCAPI($apikey);
$retval = $api->lists();
$listid='redacted';  // Enter list Id here
$teacher_1_email=shopp('purchase.data', 'name=Teacher 1 Email&return=true'); // Enter subscriber email //$teacher_1_email=$_POST['Teacher 1 Email']; // Enter subscriber email 
$teacher_1_name=shopp('purchase.firstname', 'return=true'); // Enter subscriber first name
$teacher_1_lname=shopp('purchase.lastname', 'return=true'); // Enter subscriber last name


$merge_vars = array('FNAME' => $teacher_1_name, 'LNAME' => $teacher_1_lname);
if($api->listSubscribe($listid, $teacher_1_email,$merge_vars) === true) {
}

我在没有运气的情况下上下搜索了Google和API文档。我非常感谢Ay的帮助!

谢谢!

0 个答案:

没有答案