我正在尝试使用PHP和mailchimp 2.0 api提交表单。
我收到的错误是:
FNAME must be provided
我的表单有一个名字的字段:
<input type="text" name="fname">
所以它必须与我在php方面处理它的方式有关。
以下是处理FNAME的php:
$result = $MailChimp->call('lists/subscribe', array(
'id' => 'myid',
'email' => array( 'email' => $_POST['email']),
'FNAME' => $_POST['fname'],
'LNAME' => $_POST['lname'],
'double_optin' => false,
'update_existing' => true,
'replace_interests' => false
));
我不确定我是否正确形成阵列。
顺便说一句,我正在使用这个包装器,但我认为我的错误与我如何创建$ result而不是包装器有关。
https://github.com/drewm/mailchimp-api
任何帮助都将不胜感激。
谢谢!
答案 0 :(得分:2)
窥视您链接到的页面底部的示例。我把它粘贴在这里:
$result = $MailChimp->call('lists/subscribe', array(
'id' => 'b1234346',
'email' => array('email'=>'davy@example.com'),
'merge_vars' => array('FNAME'=>'Davy', 'LNAME'=>'Jones'),
'double_optin' => false,
'update_existing' => true,
'replace_interests' => false,
'send_welcome' => false,
));
print_r($result);
您的合并变量(例如FNAME和LNAME)需要位于自己的数组中。因此,在数组中添加'merge_vars'并创建一个包含字段合并变量的数组。