Mailchimp:$merge_vars 并动态抓取表单信息

Mailchimp: $merge_vars and grabbing form information dynamically

目前..我有 mailchimp api 所有连接和工作,当我点击我的表单上的提交时,它会自动注册我的电子邮件..但是,有一个 $my_email 是预定义的以及 $merge_vars 下的数组,其预定义如下所示...

$merge_vars = array('FNAME' => 'Test', 'LNAME'=>'Account',  
);

$my_email = 'email@gmail.com';

现在,我一直在尝试提取将在邮寄表格中输入的 REAL FNAME 和 LNAME,这些表格将连同他们的信息一起传递到订阅表格,因为否则......无论如何......表格在技术上是' 除了执行 listSubscribe.php 的表单操作和提交预定义信息之外的任何事情。

如何传递此信息?我在最后一步..

我认为它会类似于 mailchimp name/id 它通过对字段名称执行 GET 请求来拉取嵌入式表单的方式。但这不是不工作,我认为它过去是如何工作的,只是在订阅者的 mailchimp 中显示为空白。

$merge_vars = Array( 
    'email' => $_GET['email'],
    'FNAME' => $_GET['FNAME'],
    'LNAME' => $_GET['LNAME'],
    'MMERGE3' => $_GET['MMERGE3'],
    'MMERGE3' => $_GET['MMERGE4']
);

澄清一下,我正在尝试通过 API 获取我的 mailchimp 表单的信息,我是如何设置的,有什么好的方法吗?

<?php

require_once 'inc/MCAPI.class.php';
require_once 'inc/config.inc.php'; //contains apikey

$api = new MCAPI($apikey);

$merge_vars = array('FNAME' => 'Test', 'LNAME'=>'Account', 
);

// By default this sends a confirmation email - you will not see new members
// until the link contained in it is clicked!
$retval = $api->listSubscribe( $listId, $my_email, $merge_vars );

if ($api->errorCode){
    echo "Unable to load listSubscribe()!\n";
    echo "\tCode=".$api->errorCode."\n";
    echo "\tMsg=".$api->errorMessage."\n";
} else {
    echo "Subscribed - look for the confirmation email!\n";
}

?>

我的表格片段..

<div class="email-form">
<div id="mc_embed_signup">
<form action="mcapi_listSubscribe.php" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
    <div id="mc_embed_signup_scroll">
    <hr>
<div class="mc-field-group">
    <label for="mce-FNAME">First Name:</label>
    <input type="text" value="" name="FNAME" class="" id="fn">
</div><hr>
<div class="mc-field-group">
    <label for="mce-LNAME">Last Name:</label>
    <input type="text" value="" name="LNAME" class="" id="ln">
</div><hr>
<div class="mc-field-group">
    <label for="mce-EMAIL">Email:  <span class="asterisk">*</span>
</label>
    <input type="email" value="" name="EMAIL" class="required email" id="em">
</div><hr>
    <label for="mce-MMERGE3">Telephone: </label>
    <input type="text" name="MMERGE3" class="tel" value="" id="tp">
    <label for="mce-MMERGE4">Zip Code: </label>
    <input type="text" value="" name="MMERGE4" class="zip" id="z">
<hr>
<div class="mc-field-group input-group">
    <input type="checkbox" value="1" name="group[17901][2]" id="real">
    <label for="chk" class="chk">I am a homebuyer</label>
    <br>
    <input type="checkbox" value="1" name="group[17901][1]" id="real">                                        
    <label for="chk" class="chk">I am a realtor/broker</label>
</div>

    <div style="position: absolute; left: -5000px;"><input type="text" name="b_2c388f1367d49e756e70a6ef2_6b9ad77da3" tabindex="-1" value=""></div>
    <div class="clear"><input type="submit" value="REGISTER" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
    </div>
</form>

<div id="mce-responses" class="clear">
        <div class="response" id="mce-error-response" style="display:none"></div>
        <div class="response" id="mce-success-response" style="display:none"></div>
    </div>    <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
</div>
</div>
<!--End mc_embed_signup-->
</div>

我使用 POST 方法对名称字段进行 GET 请求。我的错误是考虑到我的表单使用的是 POST 方法而不是 GET,我不得不执行 POST 请求。

<form action="mcapi_listSubscribe.php" method="post"

它应该看起来像..

$merge_vars = Array( 
'email' => $_POST['email'],
'FNAME' => $_POST['FNAME'],

不是...

$merge_vars = Array( 
'email' => $_GET['email'],
'FNAME' => $_GET['FNAME'],