Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rapidwebltd/simplemailchimp
🐵 Simple MailChimp API wrapper
https://github.com/rapidwebltd/simplemailchimp
mailchimp mailchimp-api php-library
Last synced: about 1 month ago
JSON representation
🐵 Simple MailChimp API wrapper
- Host: GitHub
- URL: https://github.com/rapidwebltd/simplemailchimp
- Owner: rapidwebltd
- License: lgpl-3.0
- Created: 2016-11-02T12:08:51.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-23T16:57:56.000Z (almost 7 years ago)
- Last Synced: 2024-04-13T12:59:15.872Z (8 months ago)
- Topics: mailchimp, mailchimp-api, php-library
- Language: PHP
- Homepage:
- Size: 214 KB
- Stars: 1
- Watchers: 7
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🐵 SimpleMailChimp
SimpleMailChimp is a simplified wrapper for common MailChimp functionality.
## Installation
To install this package, just use composer.
```
composer require rapidwebltd/simplemailchimp
```If your framework does not already do so, you must add `require_once "vendor/autoload.php"` to any files in which you wish to use SimpleMailChimp.
## Getting Started
In order to create a `SimpleMailChimp` object, call the `getByAPIKey` function from the `SimpleMailChimpFactory` and pass it your API key.
```php
$simpleMailChimp = SimpleMailChimpFactory::getByAPIKey('API_KEY_GOES_HERE');
```### Subscribing a user to a list
To subscribe a user to a list call the `subscribe` function and pass through the MailChimp list id and the user's email.
```php
$simpleMailChimp->subscribe('LIST_ID_GOES_HERE', '[email protected]');
```If successful it will return an array containing the subscriber's data.
### Unsubscribing a user from a list
To unsubscribe a user from a list call the `unsubscribe` function and pass through the MailChimp list id and the user's email.
```php
$simpleMailChimp->unsubscribe('LIST_ID_GOES_HERE', '[email protected]');
```If successful it will return an array containing the subscriber's data.
### Getting a subscriber's details
To get the details of a specific subscriber from a list call the `getSubscriberDetails` function and pass through the MailChimp list id and the user's email.
```php
$simpleMailChimp->getSubscriberDetails('LIST_ID_GOES_HERE', '[email protected]');
```If successful it will return an array containing the subscriber's data.
### Checking to see if a subscriber is already on a list and subscribed
To see if a subscriber is already on a list and is subscribed call the `isSubscribedToList` function and pass through the MailChimp list id and the user's email.
```php
$simpleMailChimp->isSubscribedToList('LIST_ID_GOES_HERE', '[email protected]');
```This function will return TRUE if the subscriber is found on the list AND is subscribed to it and return FALSE if either the user is not found on the list OR is in the list but set to unsubscribed.
### Getting all the members of a list
To get all the members of a list call the `getAllUsersInList` function and pass through the MailChimp list id and a comma separated list of the specific fields you want to return. If no parameters are set it retrieves the member's email by default.
```php
$simpleMailChimp->getAllUsersInList('LIST_ID_GOES_HERE');
```
Will return an array of emails belonging to members of the list specified.```php
$simpleMailChimp->getAllUsersInList('LIST_ID_GOES_HERE','email_address,status');
```
Will return an array of emails and the relevant statuses belonging to members of the list specified.
Available parameters can be found on the MailChimp API documentation page (under 'Response body parameters' -> 'members' -> 'Show properties'):
http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#read-get_lists_list_id_members.Note that this function returns all members of a list regardless of whether they are subscribed or not.