How to use the MailChimp API with PHP
https://www.a2hosting.com/kb/developer-corner/php/using-the-mailchimp-api-with-php
How to use the MailChimp API with PHP
Copycd ~ git clone https://bitbucket.org/mailchimp/mailchimp-api-php.gitCopycp -R mailchimp-api-php/src mailchimp<?php require('mailchimp/Mailchimp.php'); // You may have to modify the path based on your own configuration. $api_key = "Add your Mailchimp API key here"; $list_id = "Add your list ID here"; $Mailchimp = new Mailchimp( $api_key ); $Mailchimp_Lists = new Mailchimp_Lists( $Mailchimp ); try { $subscriber = $Mailchimp_Lists->subscribe( $list_id, array('email' => 'kellykoe@example.com'), // Specify the e-mail address you want to add to the list. array('FNAME' => 'Kelly', 'LNAME' => 'Koe'), // Set the first name and last name for the new subscriber. 'text', // Specify the e-mail message type: 'html' or 'text' FALSE, // Set double opt-in: If this is set to TRUE, the user receives a message to confirm they want to be added to the list. TRUE // Set update_existing: If this is set to TRUE, existing subscribers are updated in the list. If this is set to FALSE, trying to add an existing subscriber causes an error. ); } catch (Exception $e) { echo "Caught exception: " . $e; } if ( ! empty($subscriber['leid']) ) { echo "Subscriber added successfully."; } else { echo "Subscriber add attempt failed."; } ?>
Last updated