@@ -20,6 +20,60 @@ Or to install with phpunit:
2020
2121` composer install `
2222
23+ ## Usage
24+
25+ ### Get your account information
26+
27+ A basic test to confirm the library is set up and functional.
28+
29+ ``` php
30+ <?php
31+ require 'PATH_TO_LIBRARY/mailchimp-api-php/vendor/autoload.php';
32+ $api_key = 'YOUR_API_KEY';
33+ $mailchimp = new Mailchimp\Mailchimp($api_key);
34+
35+ // Get the account details of the authenticated user.
36+ $response = $mailchimp->getAccount();
37+
38+ // Output the account details.
39+ if (!empty($response) && isset($response->account_id)) {
40+ echo "ID: {$response->account_id}\n"
41+ . "Name: {$response->account_name}\n";
42+ }
43+ ```
44+
45+ ### Get lists and their interest categories
46+
47+ A more complicated example that takes the response from one API call and
48+ uses that data to make another.
49+
50+ ``` php
51+ <?php
52+ require 'PATH_TO_LIBRARY/mailchimp-api-php/vendor/autoload.php';
53+ $api_key = 'YOUR_API_KEY';
54+ $mailchimp_lists = new Mailchimp\MailchimpLists($api_key);
55+
56+ // Get all lists.
57+ $response = $mailchimp_lists->getLists();
58+
59+ if (!empty($response) && isset($response->lists)) {
60+ foreach ($response->lists as $list) {
61+ // Output the list name.
62+ echo "List name: {$list->name}\n";
63+
64+ // Get the list's interest categories.
65+ $interests = $mailchimp_lists->getInterestCategories($list->id);
66+
67+ // Output the names of the list's interest categories.
68+ if (!empty($interests) && isset($interests->categories)) {
69+ foreach ($interests->categories as $category) {
70+ echo "Interest category: {$category->title}\n";
71+ }
72+ }
73+ }
74+ }
75+ ```
76+
2377## Testing
2478
2579This library includes a [ PHPUnit] ( https://phpunit.de/ ) test suite.
0 commit comments