drip
v0.9
PHP library for making token-based API requests against drip.
Either download and include, or install via Composer:
composer require drewm/drip
Create a new drip object with
use DrewMdripdrip;
use DrewMdripDataset;
$drip = new drip('abc123', '1234567')
Create a new subscriber:
$data = new Dataset('subscribers', [
'email' => '[email protected]',
]);
$Response = $drip->post('subscribers', $data);
List all subscribers:
$Response = $drip->get('subscribers');
To request a method without an account ID in the URL, (e.g. list accounts) :
$drip = new drip('abc123');
$Response = $drip->getGlobal('accounts');
To then subsequently set an account ID:
$drip->setAccountID('1234567');
Methods return a Response object
if ($Response->status == 200) {
// all is ok!
$subscribers = $Response->subscribers;
} else {
echo $Response->error;
echo $Response->message;
}
Get the raw response:
$raw = $Response->get();
You can listen for webhooks in a couple of ways. The most basic is:
use DrewMdripdrip;
$data = drip::receiveWebhook();
If you prefer a pub/sub model, you can register listener callables:
use DrewMdripdrip;
drip::subscribeToWebhook('subscriber.created', function($data){
// A subscriber was created
});
drip::subscribeToWebhook('subscriber.subscribed_to_campaign', function($data){
// A subscriber was added to a campaign
});