Wordpress Membermouse获取Mailchimp的数据

时间:2017-08-06 00:16:15

标签: php wordpress mailchimp mailchimp-api-v3.0

我正在使用MemberMouse订阅Wordpress网站。我想通过API将用户数据导入php文件到Mailchimp邮件列表。

我编写了以下脚本,应该在一旦加载脚本的情况下调用它发送以下php sript:

<?php
require_once 'MCAPI.class.php';
$apikey='Your-API-Key'; // Enter your API key
$api = new MCAPI($apikey);
$retval = $api->lists();
$listid='List-Id'; // Enter list Id here

$uname = $_GET["username"]; // Enter subscriber last name

$email = $_GET["email"]; // Enter subscriber email address


$merge_vars = array('FNAME' => $uname);
if($api->listSubscribe($listid, $email,$merge_vars) === true) {
echo 'success';
}
?>

但是,它总是给我一个错误,无法读取用户数据。 这是Membermouse Wordpress Hooks:http://support.membermouse.com/support/solutions/articles/9000020294-membermouse-wordpress-hooks#member-data 这里如果使用PHP接口:https://membermouse.uservoice.com/knowledgebase/articles/319071-using-the-php-interface

MCAPI.class.php是另一个读取Mailchimp数据的php。它只是MailChimp API PHP类,我将它集成到我的项目中。

顺便说一句,通过上面的脚本手动添加成员是没有问题的:

<?php
require_once 'MCAPI.class.php';
$apikey='Your-API-Key'; // Enter your API key
$api = new MCAPI($apikey);
$retval = $api->lists();
$listid='List-Id'; // Enter list Id here
$email='Subscriber-email-address'; // Enter subscriber email address
$name='Subscriber-first-name'; // Enter subscriber first 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);
if($api->listSubscribe($listid, $email,$merge_vars) === true) {
echo 'success';
}
?>

0 个答案:

没有答案