首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用mailing v.3创建新的邮件列表并获取其id?

如何使用mailing v.3创建新的邮件列表并获取其id?
EN

Stack Overflow用户
提问于 2015-09-03 08:51:38
回答 1查看 1.6K关注 0票数 0

我从未使用过Mailchimp,我想知道是否有人可以通过这个端点来向我展示如何创建一个新的列表?然后如何获得这个列表的id (只使用列表名称),这样我就可以向它添加订阅服务器了?

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-09-03 19:13:18

使用PHP和cURL:

代码语言:javascript
复制
<?php

    $apikey = '<api-key>'; // replace with your API key
    $dc = '<data-center>'; // replace with your data center

    $data = array( // the information for your new list--not all is required
        "name" => $name,
        "contact" => array (
            "company" => $company,
            "address1" => $address1,
            "address2 => $address2,
            "city" => $city,
            "state" => $state,
            "zip" => $zip,
            "country" => $country,
            "phone" => $phone
        ),
        "permission_reminder" => $permission_reminder,
        "use_archive_bar" => $archive_bars,
        "campaign_defaults" => array(
            "from_name" => $from_name,
            "from_email" => $from_email,
            "subject" => $subject,
            "language" => $language
        ),
        "notify_on_subscribe" => $notify_subs,
        "notify_on_unsubscribe" => $notify_unsubs,
        "email_type_option" => $type,
        "visibility" => $visibility
    );
    $data = json_encode($data); // API requires JSON objects
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, "http://".$dc.".api.mailchimp.com/3.0/lists/"); // ../lists/ URL to create new list resource
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_POSTREQUEST, true); // declare request is POST type
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data); // set POST data
    curl_setopt($ch, CURLOPT_USERPWD, "user:".$apikey); // HTML Basic Auth
    $output = curl_exec($ch); // execute and capture response
    curl_close($ch); 
    print_r($output); // display API response

?>

为了更好地感受API,我强烈建议在MailChimp API游乐场中玩一玩。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32371076

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档