定制 drewm/drip 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

drewm/drip

最新稳定版本:v0.9

Composer 安装命令:

composer require drewm/drip

包简介

PHP library for interacting with the Drip API

关键字:

README 文档

README

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' => 'postmaster@example.com',
			]);
$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
});

统计信息

  • 总下载量: 120.71k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 19
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 19
  • Watchers: 2
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-24