-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
52 lines (38 loc) · 1.2 KB
/
example.php
File metadata and controls
52 lines (38 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
include_once('class-mailchimp-subscribe.php');
define('MAILCHIMP_API_KEY', '[PUT_YOUR_API_KEY]');
define('MAILCHIMP_LIST_ID', '[PUT_YOUR_LIST_ID]');
$MailChimp = new MailChimp();
/* subscribe new user */
echo '<h1>Subscribe new user</h1>';
$subscribeUser = $MailChimp->subscribe('myemail@mydomain.com', 'MyForname', 'MyLastname');
if($subscribeUser === true){
echo 'User subscribe success';
} else {
echo '<pre>';
print_r($subscribeUser);
echo '</pre>';
}
/* get user datas */
echo '<h1>Get user datas</h1>';
$getSubscribeUser = $MailChimp->getSubscriber('myemail@mydomain.com');
if($getSubscribeUser === false){
echo 'User does not exists';
} else {
echo 'email address: '.$getSubscribeUser->email_address.'<br />';
echo 'forname: '.$getSubscribeUser->merge_fields->FNAME.'<br />';
echo 'lastname: '.$getSubscribeUser->merge_fields->LNAME.'<br />';
echo 'more:';
echo '<pre>';
print_r($getSubscribeUser);
echo '</pre>';
}
/* unsubscribe user */
echo '<h1>Unsubscribe user</h1>';
$subscribeUser = $MailChimp->unSubscribe('myemail@mydomain.com');
if($subscribeUser === true){
echo 'User unsubscribe success';
} else {
print_r($subscribeUser);
}
?>