Create a basic MailChimp signup form using their API

前端 未结 3 1187
予麋鹿
予麋鹿 2020-12-02 04:23

I\'m new to MailChimp and need some help.

With their basic newsletter signup form... you simply embed some prepackaged HTML into your page. However the problem with

3条回答
  •  不知归路
    2020-12-02 05:13

    Here's another example of using version 2.0 of the Mailchimp API using the Official PHP Wrapper.

    The difference between my example and others posted here is that I'm using the subscribe method of the Mailchimp_Lists class, accessible through instantiation of the Mailchimp class (->lists), rather than the generic call method.

    $api_key = "MAILCHIMP_API_KEY";
    $list_id = "MAILCHIMP_LIST_ID";
    
    require('Mailchimp.php');
    $Mailchimp = new Mailchimp($api_key);
    $subscriber = $Mailchimp->lists->subscribe($list_id, array('email' => $_POST['email']));
    
    if ( ! empty($subscriber['leid'])) {
        // Success
    }
    

提交回复
热议问题