当前位置: 首页>>代码示例>>PHP>>正文


PHP MailChimp::validateApiKey方法代码示例

本文整理汇总了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 {
开发者ID:codeHatcher,项目名称:dewDropWebsite,代码行数:34,代码来源:store-address.php


注:本文中的MailChimp::validateApiKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。