Coder Social home page Coder Social logo

jhut89 / mailchimp-api-3.0-php Goto Github PK

View Code? Open in Web Editor NEW
64.0 4.0 24.0 2.51 MB

A feature rich object-oriented PHP library for interacting with MailChimp's API v3 ๐Ÿ’Œ๐Ÿต

License: MIT License

PHP 100.00%
mailchimp-api mailchimp-documentation php-library mailchimp oauth composer mailchimp-api-wrapper oauth2 mailchimp-php mailchimp-sdk

mailchimp-api-3.0-php's Introduction

Table Of Contents

MAILCHIMP API 3.0 PHP

GitHub license Build Status Latest Stable Version Total Downloads Slack Workspace Trello Board

This is a PHP library for interacting with version 3.0 of MailChimp's API

This library assumes a basic understanding of the MailChimp application and its associated functions.

Installation

For Composer run:

composer require jhut89/mailchimp3php

Alternatively you may add a require line to your projects composer.json for the package jhut89/mailchimp3php.

Then run composer update and add the composer autoloader to your project with:

require "vendor/autoload.php";

You can then use a use statement to pull in the Mailchimp class:

use MailchimpAPI\Mailchimp;

Instantiation

$mailchimp = new Mailchimp('123abc123abc123abc123abc-us0');

To instantiate you will need a new instance of the Mailchimp class with your MailChimp account's API key as its only argument.

OAuth

If you are using OAuth to obtain an access token, this library can handle the "handshake" for you.

You must first send the user to your applications authorize_uri. You can get this url by calling the Mailchimp::getAuthUrl() statically:

$client_id =   '12345676543';
$redirect_url =  'https://www.some-domain.com/callback_file.php';

Mailchimp::getAuthUrl($client_id, $redirect_url);

Optionally, if you need to pass state information along with your request so that the callback response can be routed correctly, you can include a state parameter:

$client_id =   '12345676543';
$redirect_url =  'https://www.some-domain.com/callback_file.php';

// state information encoded into a string to be included in the URL, for example data encoded in a JWT token
$state = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'; 

Mailchimp::getAuthUrl($client_id, $redirect_url, $state);

From there the user will input their username and password to approve your application and will be redirected to the redirect_uri you set along with a code.

With that code you can now request an access token from mailchimp. For this you will need to call the Mailchimp::oauthExchange() method statically like this:

$code = 'abc123abc123abc123abc123';
$client_id =   '12345676543';
$client_secret =  '789xyz789xyz789xyz789xyz';
$redirect_url =  'https://www.some-domain.com/callback_file.php';

Mailchimp::oauthExchange($code, $client_id, $client_secret, $redirect_url);

If the handshake is successful, then this method will return a string containing your API key like this: 123abc123abc123abc123abc123abc-us0. This API key can now be used to instantiate your Mailchimp class as we have above.

Constructing a Request

Once you have instantiated the Mailchimp class you can start constructing requests. Constructing requests is done by 'chaining' methods to the $mailchimp instance. In most cases this 'chain' will end with the HTTP verb for your request.

GET

An Example of how to retrieve a list collection:

$mailchimp
    ->lists()
    ->get();

Retrieving an instance can be accomplished by giving a unique identifier for the instance you want as an argument to the appropriate method. For example if I wanted to retrieve a list instance from the above example I would simply pass a list_id, as the only argument for the lists() method. Like this:

$mailchimp
    ->lists('1a2b3c4d')
    ->get();

Methods available for each position in the chain depend on what the prior method returns. For example if I wanted to retrieve subscribers from a list in my account I would:

$mailchimp
    ->lists('1a2b3c4d')
    ->members()
    ->get();

Notice that I provided a list_id to the lists() method, as there would be no way to retrieve a list of subscribers from a lists collection. The above request however will only return 10 subscriber instances from the members collection. This is because MailChimp's API uses pagination (documented HERE) that defaults to count=10 and offset=0. This library allows you to alter query string parameters by passing them as an argument to the GET() method. We do this by providing an array of key-value pairs where the keys are the query parameter you wish to provide/alter and its value is the parameter's value. As an example if I wanted to retrieve the second 100 subscribers from my list I could:

$mailchimp
    ->lists('1a2b3c4d')
    ->members()
    ->get([
        "count" => "100", 
        "offset" => "100"
    ]);

This would be equivalent to making a get request against:

Https://us0.api.mailchimp.com/3.0/lists/1a2b3c4d/members?count=100&offset=100

Going a little further we can retrieve a single list member by giving the members_hash (md5 hash of lower-case address) to the members() method. Like this:

$mailchimp
    ->lists('1a2b3c4d')
    ->members('8bdbf060209f35b52087992a3cbdf4d7')
    ->get();

Alternatively, in place of providing an md5 hash as the identifier to the members() function you can provide a contact's email address as a string and this library will do the hashing for you. Like this:

$mailchimp
    ->lists('1a2b3c4d')
    ->members('[email protected]')
    ->get();

You can read about GET requests in depth here: https://github.com/Jhut89/Mailchimp-API-3.0-PHP/wiki/Get-Requests

POST

While being able to retrieve data from your account is great we also need to be able to post new data. This can be done by calling the POST() method at the end of a chain. As an example subscribing an address to a list would look like this:

$post_params = [
    'email_address'=>'[email protected]', 
    'status'=>'subscribed'
];

$mailchimp
    ->lists('1a2b3c4d')
    ->members()
    ->post($post_params);

In this case I would not provide members() with an identifier as I want to post to its collection. Also notice that the post data is an array of key-value pairs representing what parameters I want to pass to the MailChimp API. Be sure that you provide all required fields for the endpoint you are posting to. Check MailChimp's documentation for what parameters are required. Non-required parameters can just be added to the post data, and MailChimp will ignore any that are unusable. To illustrate here is an example of adding a subscriber to a list with some non-required parameters:

$merge_values = [
    "FNAME" => "John",
    "LNAME" => "Doe"
];

$post_params = [
    "email_address" => "[email protected]", 
    "status" => "subscribed", 
    "email_type" => "html", 
    "merge_fields" => $merge_values
]

$mailchimp
    ->lists('1a2b3c4d')
    ->members()
    ->post($post_params);

You can read about POST requests in depth here: https://github.com/Jhut89/Mailchimp-API-3.0-PHP/wiki/Post-Requests

PATCH & PUT

This library handles PUT and PATCH request similar to that of POST requests. Meaning that PUT() & PATCH() both accept an array of key-value pairs that represent the data you wish altered/provided to MailChimp. As an example if I was patching the subscriber that we subscribed above, to have a new first name, that would look like this.

$mailchimp
    ->lists('1a2b3c4d')
    ->members('a1167f5be2df7113beb69c95ebcdb2fd')
    ->patch([
        "merge_fields" => ["FNAME" => "Jane"]
    ]);

You can read about PATCH & PUT requests in depth here: https://github.com/Jhut89/Mailchimp-API-3.0-PHP/wiki/Patch-&-Put-Requests

DELETE

Deleting a record from MailChimp is performed with the DELETE() method and is constructed similar to GET requests. If I wanted to delete the above subscriber I would:

$mailchimp
    ->lists('1a2b3c4d')
    ->members('a1167f5be2df7113beb69c95ebcdb2fd')
    ->delete();

You can read about DELETE requests in depth here: https://github.com/Jhut89/Mailchimp-API-3.0-PHP/wiki/Delete-Requests

Handling A Response

Methods named for http verbs such as get() ,post(), patch(), put(), or delete() kick off an over the wire request to MailChimp's A.P.I. Given a successful request these methods return an instance of a MailchimpResponse. I suggest you become familiar with this class as there are a number of modifiers and getters for different pieces of a response.

There are a number of getters we can use to interact with pieces our MailchimpResponse instance. Some of the more commonly used ones are:

$response->deserialize(); // returns a deserialized (to php object) resource returned by API
$response->getHttpCode(); // returns an integer representation of the HTTP response code
$response->getHeaders(); // returns response headers as an array of key => value pairs
$response->getBody(); // return the raw text body of the response

As an example, if I posses an API key but want the contact email associated with its account:

$mailchimp = new Mailchimp('123abc123abc123abc123abc-us0');
$account = $mailchimp
    ->account()
    ->get()
    
$contact_email = $account
    ->deserialize()
    ->email
    
print $contact_email; // outputs something like "[email protected]"

You can read about how to work with responses in depth here: https://github.com/Jhut89/Mailchimp-API-3.0-PHP/wiki/Handling-A-Response

Method Chart (*excluding verbs)

  mailchimp()                       
  |                                 
  |----account()                    
  |                                 
  |----apps()                       
  |                                 
  |----automations()                
  |    |                            
  |    |----removedSubscribers()    
  |    |----emails()                
  |         |                       
  |         |---queue()*             
  |         |---pauseAll()*         
  |         |---startAll()*        
  |                                 
  |----batches()                    
  |                                 
  |----batchWebhooks()              
  |                                 
  |----campaignFolders()            
  |                                 
  |----campaigns()                  
  |    |                            
  |    |----cancel()*                
  |    |----pause()*                 
  |    |----replicate()*             
  |    |----resume()*                
  |    |----scedule()*              
  |    |----send()*                  
  |    |----test()*                  
  |    |----unschedule()*            
  |    |----checklist()             
  |    |----feedback()              
  |    |----content()
  |
  |----connectedSites()
  |    |
  |    |----verifyScriptInstallation()*               
  |                                 
  |----conversations()              
  |    |                            
  |    |----messages()              
  |                                 
  |----ecommStores()                
  |    |                            
  |    |----customers()             
  |    |----products()              
  |    |    |                       
  |    |    |----variants()         
  |    |    |----images()           
  |    |     
  |    |----promoRules()
  |    |    |
  |    |    |----promoCodes()
  |    |                   
  |    |----orders()                
  |    |    |                       
  |    |    |----lines()            
  |    |                            
  |    |----carts()                 
  |         |                       
  |         |----lines()
  |
  |----facebookAds()            
  |                                 
  |----fileManagerFiles()           
  |                                 
  |----fileManagerFolders()
  |
  |----googleAds()
  |
  |----landingPages()
  |    |
  |    |----publish()*
  |    |----unpublish()*
  |    |----content()         
  |                                 
  |----lists()                      
  |    |                            
  |    |----batchSubscribe()*             
  |    |----webhooks()              
  |    |----signupForms()           
  |    |----mergeFields()           
  |    |----growthHistory()         
  |    |----clients()               
  |    |----activity()              
  |    |----abuseReports()          
  |    |----segments()              
  |    |    |                       
  |    |    |----batch()*            
  |    |    |----members()          
  |    |                            
  |    |----members()               
  |    |    |                       
  |    |    |---notes()             
  |    |    |---goals()             
  |    |    |---activity()
  |    |    |---tags()          
  |    |                            
  |    |----interestCategories()    
  |         |                       
  |         |----interests()        
  |    
  |----ping()
  |                             
  |----reports()                    
  |    |                            
  |    |----unsubscribes()          
  |    |----subReports()            
  |    |----sentTo()                
  |    |----locations()             
  |    |----emailActivity() 
  |    |----googleAnalytics()
  |    |----openDetails()        
  |    |----eepurl()                
  |    |----domainPerformance()     
  |    |----advice()                
  |    |----abuse()                 
  |    |----clickReports()          
  |         |                       
  |         |----members()          
  |                                 
  |----searchCampaigns()            
  |                                 
  |----searchMembers()              
  |                                 
  |----templateFolders()            
  |                                 
  |----templates()                  
  |    |                            
  |    |----defaultContent()        
  |                             
  |----verifiedDomains()
       |
       |----verify()                            

*Please see MailChimp's API Documentation for what verbs are appropriate where.

** Methods marked with a * make a network request

**Please watch for updates, and feel free to Fork or Pull Request. Check out the Wiki for a little more info on contributing.

mailchimp-api-3.0-php's People

Contributors

andrii-pukhalevych avatar helonaut avatar itsrexb avatar jhut89 avatar mauriciabad avatar mgilfillan avatar mmorrisson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mailchimp-api-3.0-php's Issues

Saving tags

How can we add the tags to the subscribber while creating new subscriber

$post_params = [
'EMAIL'=> $email_id,
'FNAME'=>$customer_data->getData()['First_Name'],
"LNAME"=>$customer_data->getData()['Last_Name'],
"KLANTNAAM"=>,
"KLANTNR"=>,
"INDUSTRIE"=>,
"TOER"=>,
'status'=>'subscribed'
	];

Should i need to add tags as key in above array ?

$mailchimp
->lists(LIST_ID)
->members()
->post($post_params);

Typo in Wiki: Method $response->wasSuccessful() is incorrect

Minor bug in wiki:

$response->wasSuccessful() // returns true if the http code is in the 200 range

To Reproduce
Just visit the wiki in Handling a Response Section

Expected behavior
Text must be:

$response->wasSuccess() // returns true if the http code is in the 200 range

curl_exec($this->handle) echoes HTTP response

To Reproduce

$api3 = new Mailchimp($apikey);
$reports = $api3->reports($cid)->unsubscribes()->get()->deserialize(true);

Description

The request echoes this:

string(17) "HTTP/1.1 200 OK " string(19) "Server: openresty " string(47) "Content-Type: application/json; charset=utf-8 " string(21) "Content-Length: 477 " string(23) "Vary: Accept-Encoding " string(52) ...

Expected behavior

$reports contains only the deserialized content of the request body the without echoing anything.

Where is this happening?

I think the problem is here

$this->setOption(CURLOPT_RETURNTRANSFER, true); // at MailchimpConnection.php line 112

OR

return curl_exec($this->handle); // at MailchimpConnection.php line 228 

Additional comment

Maybe I'm doing something wrong ๐Ÿ˜… .

Namespaces

Hey, first for all thx for your library. Can you add namespaces to your classes? Cuz class name "Lists", for example, its very common name, which use in many legacy projects.

Oauth error

I tried to use oAuth2 to get api key, but get error on sending request to get access token.

screen shot 2018-10-04 at 4 53 45 pm

does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0.

Describe the bug

using composer, I get the notices:

Deprecation Notice: Class MailchimpTests\Resources\Automations\EmailsTest located in ./vendor/jhut89/mailchimp3php/tests/Automations/EmailsTest.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0

The same for classes:

MailchimpTests\Resources\Automations\Emails\QueueTest located in ./vendor/jhut89/mailchimp3php/tests/Automations/Emails/QueueTest.php

MailchimpTests\Resources\Automations\RemovedSubscribersTest located in ./vendor/jhut89/mailchimp3php/tests/Automations/RemovedSubscribersTest.php

To Reproduce
Steps to reproduce the behavior:

  1. in composer.json : "jhut89/mailchimp3php": "^3.1",
    (in composer.lock the version is now:
    "name": "jhut89/mailchimp3php",
    "version": "3.2.1",
  2. composer update/install

Expected behavior
no warnings

Additional context

composer version 1.10.5

lots of warnings about function declarations

Backtrace from warning 'Declaration of Campaigns_Feedback::POST() should be compatible with Campaigns::POST($type, $settings = Array, $optional_parameters = Array)' at \mailchimp-api-3-0-php\campaigns\campaignsFeedback.php 64:

Backtrace from warning 'Declaration of Campaigns_Feedback::PATCH() should be compatible with Campaigns::PATCH($params = Array)' at \mailchimp-api-3-0-php\campaigns\campaignsFeedback.php 64:

Backtrace from warning 'Declaration of Ecommerce_Customers::POST() should be compatible with Ecommerce_Stores::POST($storeid, $listid, $name, $currencycode, $optional_parameters = Array)' at \mailchimp-api-3-0-php\ecommerceStores\ecommerceStoresCustomers.php 96:

Backtrace from warning 'Declaration of Ecommerce_Store_Carts::POST() should be compatible with Ecommerce_Stores::POST($storeid, $listid, $name, $currencycode, $optional_parameters = Array)' at \mailchimp-api-3-0-php\ecommerceStores\carts\ecommerceStoresCartsRoot.php 94:

Backtrace from warning 'Declaration of Ecommerce_Stores_Cart_Lines::POST() should be compatible with Ecommerce_Store_Carts::POST($cartid, $customer, $currency_code, $order_total, $lines, $optional_parameters = Array)' at \mailchimp-api-3-0-php\ecommerceStores\carts\ecommerceStoresCartLines.php 71:

Backtrace from warning 'Declaration of Ecommerce_Stores_Orders::POST() should be compatible with Ecommerce_Stores::POST($storeid, $listid, $name, $currencycode, $optional_parameters = Array)' at \mailchimp-api-3-0-php\ecommerceStores\orders\ecommerceStoresOrdersRoot.php 99:

Backtrace from warning 'Declaration of Ecommerce_Stores_Order_Lines::POST() should be compatible with Ecommerce_Stores_Orders::POST($orderid, $customer, $currency_code, $order_total, $lines, $optional_parameters = Array)' at \mailchimp-api-3-0-php\ecommerceStores\orders\ecommerceStoresOrderLines.php 72:

Backtrace from warning 'Declaration of Ecommerce_Stores_Products::POST() should be compatible with Ecommerce_Stores::POST($storeid, $listid, $name, $currencycode, $optional_parameters = Array)' at \mailchimp-api-3-0-php\ecommerceStores\products\ecommerceStoresProductsRoot.php 92:

Backtrace from warning 'Declaration of Ecommerce_Stores_Products_Variants::POST() should be compatible with Ecommerce_Stores_Products::POST($productid, $title, $variants = Array, $optional_parameters = Array)' at \mailchimp-api-3-0-php\ecommerceStores\products\ecommerStoresProductVariants.php 91:

Backtrace from warning 'Declaration of Lists_Merge_Fields::POST() should be compatible with Lists::POST($name, $reminder, $emailtype, $company, $address_street, $address_street2, $address_city, $address_state, $address_zip, $country, $from_name, $from_email, $subject, $language, $optional_parameters = Array)' at \mailchimp-api-3-0-php\lists\listsMergeFields.php 68:

Backtrace from warning 'Declaration of Lists_Merge_Fields::PATCH() should be compatible with Lists::PATCH($patch_params = NULL)' at \mailchimp-api-3-0-php\lists\listsMergeFields.php 68:

Backtrace from warning 'Declaration of Lists_Signup_Forms::POST() should be compatible with Lists::POST($name, $reminder, $emailtype, $company, $address_street, $address_street2, $address_city, $address_state, $address_zip, $country, $from_name, $from_email, $subject, $language, $optional_parameters = Array)' at \mailchimp-api-3-0-php\lists\listsSignupForms.php 40:

Backtrace from warning 'Declaration of Lists_Webhooks::POST() should be compatible with Lists::POST($name, $reminder, $emailtype, $company, $address_street, $address_street2, $address_city, $address_state, $address_zip, $country, $from_name, $from_email, $subject, $language, $optional_parameters = Array)' at \mailchimp-api-3-0-php\lists\listsWebhooks.php 59:

Backtrace from warning 'Declaration of Lists_Interest_Categories::POST() should be compatible with Lists::POST($name, $reminder, $emailtype, $company, $address_street, $address_street2, $address_city, $address_state, $address_zip, $country, $from_name, $from_email, $subject, $language, $optional_parameters = Array)' at \mailchimp-api-3-0-php\lists\interestCategories\listsInterestsCategoriesRoot.php 82:

Backtrace from warning 'Declaration of Lists_Interest_Categories::PATCH() should be compatible with Lists::PATCH($patch_params = NULL)' at \mailchimp-api-3-0-php\lists\interestCategories\listsInterestsCategoriesRoot.php 82:

Backtrace from warning 'Declaration of Lists_Interests_Categories_Interest::POST() should be compatible with Lists_Interest_Categories::POST($title, $type)' at \mailchimp-api-3-0-php\lists\interestCategories\listsInterestsCategroiesInterests.php 66:

Backtrace from warning 'Declaration of Lists_Interests_Categories_Interest::PATCH() should be compatible with Lists_Interest_Categories::PATCH($title, $type)' at \mailchimp-api-3-0-php\lists\interestCategories\listsInterestsCategroiesInterests.php 66:

Backtrace from warning 'Declaration of Lists_Members::POST() should be compatible with Lists::POST($name, $reminder, $emailtype, $company, $address_street, $address_street2, $address_city, $address_state, $address_zip, $country, $from_name, $from_email, $subject, $language, $optional_parameters = Array)' at \mailchimp-api-3-0-php\lists\members\listsMembersRoot.php 129:

Backtrace from warning 'Declaration of Lists_Members_Member_Notes::POST() should be compatible with Lists_Members::POST($status, $emailaddress, $optional_parameters = Array)' at \mailchimp-api-3-0-php\lists\members\listsMembersMemberNotes.php 67:

Backtrace from warning 'Declaration of Lists_Members_Member_Notes::PATCH() should be compatible with Lists_Members::PATCH($patch_parameters = Array)' at \mailchimp-api-3-0-php\lists\members\listsMembersMemberNotes.php 67:

Backtrace from warning 'Declaration of Lists_Segments::POST() should be compatible with Lists::POST($name, $reminder, $emailtype, $company, $address_street, $address_street2, $address_city, $address_state, $address_zip, $country, $from_name, $from_email, $subject, $language, $optional_parameters = Array)' at \mailchimp-api-3-0-php\lists\segments\listsSegmentsRoot.php 103:

Backtrace from warning 'Declaration of Lists_Segments::PATCH() should be compatible with Lists::PATCH($patch_params = NULL)' at \mailchimp-api-3-0-php\lists\segments\listsSegmentsRoot.php 103:

Backtrace from warning 'Declaration of Lists_Segment_Segment_Members::POST() should be compatible with Lists_Segments::POST($name, $conditions = NULL, $static_segment = NULL)' at \mailchimp-api-3-0-php\lists\segments\listsSegmentsSegmentMembers.php 54:

Not response

After the request is not response

  1. Include the https://github.com/Jhut89/Mailchimp-API-3.0-PHP#post library.
  2. Then I execute the query (new Mailchimp ($ this-> secretKey)) -> lists ($ this-> listId) -> members () -> post ($ post_params);
    other methods don't return anything either
  3. $ post_params = ['email_address' => $ email, 'status' => 'pending', 'merge_fields' => ['FNAME' => $ this-> user-> name,]];

I expected to see the answer as described here.
https://github.com/Jhut89/Mailchimp-API-3.0-PHP/wiki/Post-Requests
2019-02-19 16-45-59

Build Failing

Describe the bug
A build dependency is failing due to 5.6 deprecation of a dev dependent package.

Additional context
I will likely update the required minimum php version to resolve.

Unable to deserialize response

Describe the bug
When trying to call Mailchimp::oauthExchange it always shows the exception Unable to deserialize response

Expected behavior
It should return the apiKey

Additional context
I checked the code and tried printed out the response and got the body correct but in the file Mailchimp.php (304) line produces the exception, though on deserialize method i tried printing the body and decoded data which prints well

SuccessResponse does not properly call success callback.

Describe the bug
The success callback is not called correctly by the SuccessResponse construct.

To Reproduce
See this line: https://github.com/Jhut89/Mailchimp-API-3.0-PHP/blob/master/src/Responses/SuccessResponse.php#L27

Expected behavior
A success callback should be executed when a request is successful.

Additional context
Some of the logic in these construct could be simplified. Consider cleaning this up.
Will require a release once fixed.

Also note to self:
A unit test would have prevented this. Write more unit tests!

New endpoints since last update

It appears MailChimp has added some new endpoints since this library's last update. I will look into adding support for those shortly.

Setting the user-agent

Is it possible to set the user agent string when using this wrapper? This is encouraged by Mailchimp so they can identify our integration in their logs.

Thanks in advance!

Add Webhook

Can you add a function so I can add webhooks to a list?

Updating setting constants from outside

Hello,

I am trying to update settings from where this library is called.

<?php
include('mailchimp-api-3.0-php/vendor/autoload.php');

$api_key = '123abc123abc123abc123abc-us0';
$list_id = '132465789';

if (!defined('VERIFY_SSL')) {
    define('VERIFY_SSL', false);
}

$mailchimp = new Mailchimp($api_key);

$post_params = array(
	'email_address' => '[email protected]',
	'status'        => 'subscribed'
);
$response = $mailchimp->lists($list_id)->members()->POST($post_params);

So, if constants can be updated from construtor, it can be more helpful.

Array 'literal' syntax preventing PHP 5.3 compatibility

Hello, this package was listed as "php": ">=5.3.0" on packagist.org. However the use of the new array syntax introduced in php 5.4 is used extensively, preventing compatibility with 5.3.

    public $req_post_prarams = [
        'operations'
    ];

Should be

    public $req_post_prarams = array(
        'operations'
    );

But only if you want to keep php 5.3 compatibility, which I know is a hassle :) Regardless, as it is now the packagist php version requirement is incorrect, so you'd need to either bump the required version, or downgrade the array syntax to fix.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.