本文整理汇总了PHP中MailChimp::validateApiKey方法的典型用法代码示例。如果您正苦于以下问题:PHP MailChimp::validateApiKey方法的具体用法?PHP MailChimp::validateApiKey怎么用?PHP MailChimp::validateApiKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MailChimp
的用法示例。
在下文中一共展示了MailChimp::validateApiKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: storeAddress
Part of the code from the book
Building Findable Websites: Web Standards, SEO, and Beyond
by Aarron Walter (aarron@buildingfindablewebsites.com)
http://buildingfindablewebsites.com
Distrbuted under Creative Commons license
http://creativecommons.org/licenses/by-sa/3.0/us/
///////////////////////////////////////////////////////////////////////*/
function storeAddress()
{
// Validation
if (empty($_REQUEST['email'])) {
return "No email address provided";
}
if (!preg_match("/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*\$/i", $_REQUEST['email'])) {
return "Email address is invalid";
}
// grab an API Key from http://admin.mailchimp.com/account/api/
$api_key = 'your-api-code-here';
// grab your List's Unique Id by going to http://admin.mailchimp.com/lists/
// Click the "settings" link for the list - the Unique Id is at the bottom of that page.
$list_id = "your-list-id-here";
require_once 'MailChimp.php';
$dopt = !empty($_REQUEST['dopt']) && $_REQUEST['dopt'] == 'true' ? true : false;
$email = $_REQUEST['email'];
$merge_vars = array('FNAME' => !empty($_REQUEST['fname']) ? $_REQUEST['fname'] : '', 'LNAME' => !empty($_REQUEST['lname']) ? $_REQUEST['lname'] : '');
$api = new MailChimp($api_key);
$valid_key = $api->validateApiKey();
if (!$valid_key) {
return 'Error: please, check your api-key';
}
$result = $api->call('lists/subscribe', array('id' => $list_id, 'email' => array('email' => $email), 'merge_vars' => $merge_vars, 'double_optin' => $dopt, 'update_existing' => true, 'replace_interests' => false, 'send_welcome' => false));
if (!empty($result['email']) && !empty($result['euid']) && !empty($result['leid'])) {
return 'Success! Check your email to confirm sign up.';
} else {