Skip to content

Commit c2fe997

Browse files
committed
Clearer instructions
1 parent 19733c3 commit c2fe997

1 file changed

Lines changed: 28 additions & 10 deletions

File tree

README.md

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,48 @@ include('./Mailchimp.php');
3131
Examples
3232
--------
3333

34-
List all the mailing lists (`lists` method)
34+
Start by `use`-ing the class and creating an instance with your API key
3535

3636
```php
3737
use \DrewM\MailChimp\MailChimp;
3838

39-
$MailChimp = new MailChimp('abc123abc123abc123abc123abc123-us1');
40-
print_r($MailChimp->get('lists'));
39+
$MailChimp = new MailChimp('abc123abc123abc123abc123abc123-us1')
4140
```
4241

43-
Subscribe someone to a list and an interest group
42+
Then, list all the mailing lists (with a `get` on the `lists` method)
4443

4544
```php
46-
use \DrewM\MailChimp\MailChimp;
45+
$result = $MailChimp->get('lists');
46+
47+
print_r($result);
48+
```
4749

48-
$MailChimp = new MailChimp('abc123abc123abc123abc123abc123-us1');
49-
$result = $MailChimp->post('lists/b1234346/members', array(
50+
Subscribe someone to a list (with a `post` to the `list/{listID}/members` method):
51+
52+
```php
53+
$result = $MailChimp->post('lists/b1234346/members', [
5054
'email_address' => 'davy@example.com',
5155
'status' => 'subscribed',
52-
'merge_fields' => array('FNAME'=>'Davy', 'LNAME'=>'Jones'),
53-
'interests' => array( '2s3a384h' => true )
54-
));
56+
]);
5557
print_r($result);
5658
```
5759

60+
Update a list member with more information (using `put` to update):
61+
62+
```php
63+
$result = $MailChimp->put('lists/b1234346/members/c67894321', [
64+
'merge_fields' => ['FNAME'=>'Davy', 'LNAME'=>'Jones'],
65+
'interests' => ['2s3a384h' => true],
66+
]);
67+
print_r($result);
68+
```
69+
70+
Remove a list member using the `delete` method:
71+
72+
```php
73+
$MailChimp->delete('lists/b1234346/members/c67894321');
74+
```
75+
5876
Troubleshooting
5977
---------------
6078

0 commit comments

Comments
 (0)