Get Started with the PHP SDK
Download the PHP SDK from GitHub. Make sure you install all dependencies as described in the SDK’s README.
In our code samples, we assume you place the downloaded files in a subdirectory of your workspace called sdk
. You'll want to adapt the code to your local environment.
The PHP SDK is configured via the config.php
file. Add your client ID and secret to this file. It is safe to include your client ID and secret in config.php
because config.php
is hosted server side and not exposed to the client. Here's an example config.php
:
Once the SDK is configured, initialize it by instantiating an ET_Client
object:
The ET_Client
object is the central object in the SDK and performs a number of tasks for you automatically, including acquiring and refreshing OAuth access tokens using the client credentials you specified in the last step.
Once the SDK is initialized, you can use it to programmatically interact with the account represented by the ET_Client
instance. Here's an example of the SDK being used to retrieve all lists in an account:
This code sample highlights the pattern for interacting with objects in the PHP SDK. First, you instantiate an ET_Client
object. Then, you instantiate an object of the type you want to work with, in this example ET_List
. Then, you specify account context (the ET_Client
instance) for the operation using the authStub
property. Finally, you perform a REST-style operation on the object: get
(retrieve), post
(create), patch
(update), or delete
.