Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Documentation #271

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,36 +42,58 @@ These are optional. If you're not using batches or webhooks you can just skip th
Examples
--------

Start by `use`-ing the class and creating an instance with your API key
#### Start by `use`-ing the class and creating an instance with your API key

```php
use \DrewM\MailChimp\MailChimp;

$MailChimp = new MailChimp('abc123abc123abc123abc123abc123-us1');
```

Then, list all the mailing lists (with a `get` on the `lists` method)
#### Then, list all the mailing lists (with a `get` on the `lists` method)

```php
$result = $MailChimp->get('lists');

print_r($result);
```

Subscribe someone to a list (with a `post` to the `lists/{listID}/members` method):
#### Subscribe someone to a list (with a `post` to the `lists/{listID}/members` method):

Possible values for `status`:
- `subscribed` - the user will be immediatly subscribed to the list without opt-in email
- `pending` - the user will be sent an opt-in email before being added to the list

```php
$list_id = 'b1234346';

$result = $MailChimp->post("lists/$list_id/members", [
'email_address' => 'davy@example.com',
'status' => 'subscribed',
'status' => 'pending',
]);

print_r($result);
```

#### Subscribe someone to a list with additional fields (with a `post` to the `lists/{listID}/members` method):

```php
$list_id = 'b1234346';

$result = $MailChimp->post("lists/$list_id/members", [
'email_address' => 'davy@example.com',
'status' => 'pending',
'marketing_permissions' => [
['marketing_permission_id' => 'xxxxxxxxxx', 'enabled' => true],
['marketing_permission_id' => 'yyyyyyyyyy', 'enabled' => true],
],
'merge_fields' => ['FNAME'=>'Davy', 'LNAME'=>'Jones'],
]);

print_r($result);
```

Update a list member with more information (using `patch` to update):
#### Update a list member with more information (using `patch` to update):

```php
$list_id = 'b1234346';
Expand All @@ -85,7 +107,7 @@ $result = $MailChimp->patch("lists/$list_id/members/$subscriber_hash", [
print_r($result);
```

Remove a list member using the `delete` method:
#### Remove a list member using the `delete` method:

```php
$list_id = 'b1234346';
Expand All @@ -94,7 +116,7 @@ $subscriber_hash = $MailChimp->subscriberHash('davy@example.com');
$MailChimp->delete("lists/$list_id/members/$subscriber_hash");
```

Quickly test for a successful action with the `success()` method:
#### Quickly test for a successful action with the `success()` method:

```php
$list_id = 'b1234346';
Expand Down