subscriberHash() public method

Convert an email address into a 'subscriber hash' for identifying the subscriber in a method URL
public subscriberHash ( string $email ) : string
$email string The subscriber's email address
return string Hashed version of the input
Ejemplo n.º 1
0
 public function testSubscriberHash()
 {
     $MC_API_KEY = getenv('MC_API_KEY');
     if (!$MC_API_KEY) {
         $this->markTestSkipped('No API key in ENV');
     }
     $MailChimp = new MailChimp($MC_API_KEY);
     $email = '*****@*****.**';
     $expected = md5(strtolower($email));
     $result = $MailChimp->subscriberHash($email);
     $this->assertEquals($expected, $result);
 }
Ejemplo n.º 2
0
    <body>
        <h2>Mailchimp demo</h2>
        <?php 
include 'libraries/Mailchimp.php';
use DrewM\MailChimp\MailChimp;
$mailChimp = new MailChimp('your-api-key-goes-here');
print_r('Getting list...<br><br>');
//get all lists
$listData = $mailChimp->get('lists');
//if lists exist, get the id of the first list and add a subscriber to it.
if ($listData) {
    $listId = $listData['lists'][0]['id'];
    print_r('Mailchimp list id is: ' . $listId . '<br><br>');
    $subscriberEmail = '*****@*****.**';
    print_r('Adding subscriber...<br><br>');
    //add subscriber
    $subscriber = $mailChimp->post("lists/{$listId}/members", ['email_address' => $subscriberEmail, 'status' => 'subscribed']);
    if (isset($subscriber['id'])) {
        print_r('Mailchimp subscriber id is: ' . $subscriber['id'] . '<br><br>');
        print_r('Deleting subscriber...<br><br>');
        //delete the subscriber
        $subscriber_hash = $mailChimp->subscriberHash($subscriberEmail);
        $mailChimp->delete("lists/{$listId}/members/{$subscriber_hash}");
    } else {
        print_r($subscriber['detail'] . '<br><br>');
    }
}
?>
    </body>
</html>
Ejemplo n.º 3
0
 /**
  * @param string $email
  *
  * @return string
  */
 protected function getSubscriberHash($email)
 {
     return $this->mailChimp->subscriberHash($email);
 }