Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zbycz/mailchimp-v3-php
PHP service class for Mailchimp v3 API subscriptions
https://github.com/zbycz/mailchimp-v3-php
Last synced: 26 days ago
JSON representation
PHP service class for Mailchimp v3 API subscriptions
- Host: GitHub
- URL: https://github.com/zbycz/mailchimp-v3-php
- Owner: zbycz
- Created: 2015-06-05T16:30:56.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-06-07T09:00:07.000Z (over 9 years ago)
- Last Synced: 2024-04-24T09:36:38.005Z (8 months ago)
- Language: PHP
- Size: 129 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Mailchimp v3 PHP
PHP service class for managining Mailchimp v3 API subscriptions.
## Example usage
```php
$conf = [
'apiurl' => 'https://us11.api.mailchimp.com/3.0/',
'apikey' => 'someApiKeyb497cd07a4-us11',
'list' => '87421ce950', // list id from https://us11.api.mailchimp.com/playground/
'logfile' => 'mailchimp.log'
];
$user = (object)['id' => 53]; // for loging purposes only$mailchimp = new Services\Mailchimp($conf, $user);
$mail = '[email protected]';
$mailchimp->getStatus($mail) // == FALSE;
$mailchimp->subscribe($mail, 'jm', 'př') // nothing returned
$mailchimp->getStatus($mail) // == 'subscribed';
$mailchimp->delete($mail) // nothing returned
$mailchimp->getStatus($mail) // == FALSE;
```Request played for the example above:
```
2015-06-05 18:15:08 (uid=53) GET /lists/87421ce950/members/50ed17fa41ba3906dade48038810de77 >>> 404 {"type":"http://kb.mailchimp.com/api/error-docs/404-resource-not-found",...}2015-06-05 18:15:08 (uid=53) GET /lists/87421ce950/members/50ed17fa41ba3906dade48038810de77 >>> 404 {"type":"http://kb.mailchimp.com/api/error-docs/404-resource-not-found",...}
2015-06-05 18:15:09 (uid=53) POST /lists/87421ce950/members{"email_address":"[email protected]","merge_fields":{"FNAME":"jm","LNAME":"p\u0159"},"status":"subscribed"} >>> 200 {"id":"50ed17fa41ba3906dade48038810de77","email_address":"[email protected]","status":"subscribed"...}2015-06-05 18:15:09 (uid=53) GET /lists/87421ce950/members/50ed17fa41ba3906dade48038810de77 >>> 200 {"id":"50ed17fa41ba3906dade48038810de77","email_address":"[email protected]","status":"subscribed"...}
2015-06-05 18:15:09 (uid=53) DELETE /lists/87421ce950/members/50ed17fa41ba3906dade48038810de77 >>> 204
2015-06-05 18:15:09 (uid=53) GET /lists/87421ce950/members/50ed17fa41ba3906dade48038810de77 >>> 404 {"type":"http://kb.mailchimp.com/api/error-docs/404-resource-not-found","title":"Resource Not Found","status":404,"detail":"The requested resource could not be found.","instance":"bad7b267-b946-4024-a5bb-127b7ffe5178"}
```## Nette framework integration
```yaml
common:
parameters:
mailchimp:
apiurl: https://us11.api.mailchimp.com/3.0/
apikey: someApiKeyb497cd07a4-us11
list: 87421ce950
logfile: %logDir%/mailchimp.log
services:
mailchimp: Services\MailchimpService(%mailchimp%, @user)
```Usage in presenter:
```php
$this->context->mailchimp->subscribe($mail, 'jm', 'pø');
```## Author and licence
(c) 2015 [Pavel Zbytovský](http://zby.cz)
Licenced under MIT license.