Coder Social home page Coder Social logo

drip's Introduction

Drip

PHP library for making token-based API requests against Drip.

Build Status Scrutinizer Code Quality

Install

Either download and include, or install via Composer:

composer require drewm/drip

Make a simple request

Create a new Drip object with

  1. Your user's API token (Settings > My User Settings > API Token)
  2. Your numeric account ID (Log into the Drip dashboard and it's the first segment in your URL)
use DrewM\Drip\Drip;
use DrewM\Drip\Dataset;

$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');

Handling responses

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();

Webhooks

You can listen for webhooks in a couple of ways. The most basic is:

use DrewM\Drip\Drip;
$data = Drip::receiveWebhook();

If you prefer a pub/sub model, you can register listener callables:

use DrewM\Drip\Drip;

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
});

drip's People

Contributors

drewm avatar slaffik avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

drip's Issues

Posting Batches Not Working

Single updates work great. For some reason, getting this error when posting to `/subscribers/batches':

Subscribers must contain between 1 and 1000 items

Data before being sent is:

Dataset {#2564 ▼
#label: "subscribers"
#data: array:120 [▼

Any idea what is wrong here?

Timeout 10 seconds

Thank you so much for this library! Very handy with a recent job.

Please consider changing the timeout value to 30 seconds.

I had some batch calls that were pressing the limit of the Drip api. (500 contacts, 100 custom fields per contact, a few tags per contact). I was getting a timeout every 40-60 calls. I moved the timeout to 30 seconds and this was resolved.

makeRequest() is account specific

Method makeRequest() is account specific, as it assumes that all API requests are made against a certain account.

Although, Drip API allows to make top-level requests, like /accounts: http://developer.drip.com/#accounts

With that, your library and its get() etc methods are useless in certain scenarios, and developers need to extend the class to create own makeRawRequest() method (or similar, to send requests without accountID in request URL).
But while extending we face with a problem in #4.

Why properties are private?

Private properties don't allow to reuse them in own class, that extends Drip from this library. Example, $this->api_endpoint usage in own method.

Please make them protected.

Require PHP 7.1?

Why are you requiring 7.1? I see that you added a return typehint - and that's all.

This is a breaking change, so it will be a 1.0 release, I suppose?

I won't be able to use it in my project than, and will need to stay with 0.8 :(

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.