【发布时间】:2015-03-13 01:47:44
【问题描述】:
目前..我的 mailchimp api 已全部连接并正常工作,当我在表单上单击提交时,它会自动注册我的电子邮件。但是,有一个预定义的 $my_email 以及预定义的 $merge_vars 下的数组如下图...
$merge_vars = array('FNAME' => 'Test', 'LNAME'=>'Account',
);
$my_email = 'email@gmail.com';
现在,我一直在尝试提取将在邮件表单中输入的 REAL FNAME 和 LNAME,该邮件表单将与他们的信息一起传递到订阅表单,否则......无论如何......从技术上讲,表单不是除了拥有 listSubscribe.php 的表单操作和提交预定义的信息之外,还可以做任何事情。
如何传递此信息?我在最后一步..
我认为它会类似于 mailchimp 名称/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>
【问题讨论】:
-
简化:我正在尝试提取用户在访问网站时输入的邮件表单上的信息,当他们点击提交时。它传递了所有这些信息(比如他们的 FNAME 和 LNAME ) 并动态发送,而不是 mailchimp 给出的静态内容和示例。
标签: php jquery forms api mailchimp