目前..我有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>
答案 0 :(得分:0)
我正在使用POST方法和名称字段的GET请求。我的错误是我必须做一个POST请求,因为我的表单使用的是POST方法而不是GET。
<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'],