mmollick/drip-php
Composer 安装命令:
composer require mmollick/drip-php
包简介
Community supported library for Drip.com's API
README 文档
README
Requirements
- PHP 5.6 or greater
- PHP JSON extension
- PHP cURL extension
Installation
Composer Installation
Run the following command in the terminal:
composer require mmollick/drip-php
Or add the following to your composer.json file:
{
"require": {
"mmollick/drip-php":"~0.1.0"
}
}
Manual Installation
This package conforms to the PSR-4 autoloading standard. To include it in your project we recommend using composer, however you can use your own PSR-4 autoloader or manually load all the files contained in the src directory to load this library.
Usage
This package allows you use it in both an object-oriented or singleton approach depending on your preferences. All authentication and request methods are available with either approach.
Initialization as Singleton
Specify your authentication credentials with either the setTokenCredentials or setOAuthAccessToken static methods on the Drip class.
// Authenticating w/ API key \MMollick\Drip\Drip::setTokenCredentials($accountId, $api_key) // Authenticating w/ OAuth access_token \MMollick\Drip\Drip::setOAuthAccessToken($accountId, $access_token)
Initialization as Object
Using the object-oriented approach allows you to create multiple isolated instances of the Drip API. To do this first create new a \MMollick\Drip\Auth object and pass this into a new \MMollick\Drip\Request object.
// Authentication w/ API Key $auth = new \MMollick\Drip\Auth($account_id, $api_key); $drip = new \MMollick\Drip\Request($auth); // Authentication w/ OAuth access_token $authUsingOauth = new \MMollick\Drip\Auth($account_id, $access_token, true); $dripUsingOauth = new \MMollick\Drip\Request($authUsingOauth);
Error Handling
This library will throw one of several exceptions when an error occurs either with the Request or the package itself. It's recommended that requests are made within in a try...catch block to properly handle errors as they arise. See the example below.
try { $drip->getSubscribers(); } catch (\MMollick\Drip\Errors\AuthException $e) { // Authentication failed, check API keys } catch (\MMollick\Drip\Errors\ValidationException $e) { //The request failed validation, see message or $e->getErrors() for more info } catch (\MMollick\Drip\Errors\ApiExceptions $e) { // Non-specific API error returned, see message or $e->getErrors() for more info } catch (\MMollick\Drip\Errors\RateLimitException $e) { // Requests are being throttled, try the request again in a while } catch (\MMollick\Drip\Errors\HttpClientException $e) { // Most likely a network or Curl related error, see the message for more details } catch (\MMollick\Drip\Errors\GeneralException $e) { // A generic exception, see message for details } catch (\Exception $e) { // Catch anything else just for good measure }
Methods
All of the request methods can be accessed statically from the \MMollick\Drip\Drip class or by calling them from the \MMollick\Drip\Request object.
Account
| Actions | Methods |
|---|---|
| List accounts | getAccounts() |
| Fetch an account | getAccount($account_id) |
Broadcasts
| Actions | Methods |
|---|---|
| List broadcasts | getBroadcasts($options = []) |
| Fetch a broadcast | getBroadcast($broadcast_id) |
Campaigns
| Actions | Request Methods |
|---|---|
| List campaigns | getCampaigns($options = []) |
| Fetch a campaign | getCampaign($campaign_id) |
| Activate a campaign | activateCampaign($campaign_id) |
| Pause a campaign | pauseCampaign($campaign_id) |
| List campaign subscribers | listCampaignSubscribers($campaign_id, $options = []) |
| Subscribe to a campaign | subscribeToCampaign($campaign_id, $subscriber) |
Campaign Subscriptions
| Actions | Methods |
|---|---|
| List subscriber's subscriptions | See listSubscribersSubscriptions in Subscribers |
Conversions
| Actions | Methods |
|---|---|
| List all conversions | getConversions($options = []) |
| Fetch a conversion | getConversion($conversion_id) |
Custom Fields
| Actions | Methods |
|---|---|
| List all custom fields | getCustomFields() |
Events
| Actions | Methods |
|---|---|
| Track an event | recordEvent($payload) |
| Track a batch of events | recordEvents($events) |
| List all custom event actions | listActions() |
Forms
| Actions | Methods |
|---|---|
| List all forms | getForms($options = []) |
| Fetch a form | getForm($form_id) |
Purchases
| Actions | Methods |
|---|---|
| List purchases for a subscriber | getPurchasesForSubscriber($id_or_email, $options = []) |
| Create a purchase | addPurchaseToSubscriber($id_or_email, $purchase_id) |
| Fetch a purchase | getPurchaseForSubscriber($id_or_email, $payload) |
Subscribers
| Actions | Methods |
|---|---|
| List subscribers | getSubscribers($options = []) |
| Create/update a subscriber | createOrUpdateSubscriber($email, $payload = {}) |
| Create/update a batch of subscribers | createOrUpdateSubscribers($subscribers) |
| Unsubscribe a batch of subscribers | unsubscribeSubscribers($subscribers) |
| Fetch a subscriber | getSubscriber($id_or_email) |
| Delete | deleteSubscriber($id_or_email) |
| Subscribe to a campaign | See subscribeToCampaign in Campaigns |
| Unsubscribe from all mailings | removeSubscriberFromAllMailings($id_or_email) |
| Unsubscribe from campaigns | removeSubscriberFromCampaigns($id_or_email, $campaign_id = null) |
| List subscriber's subscriptions | listSubscribersSubscriptions($subscriber_id) |
Tags
| Actions | Methods |
|---|---|
| List tags | getTags() |
| Apply a tag | applyTag($email, $tag) |
| Remove a tag | removeTag($email, $tag) |
Webhooks
| Actions | Methods |
|---|---|
| List webhooks | getWebhooks() |
| Fetch a webhook | getWebhook($webhook_id) |
| Create a new webhook | createWebhook($payload) |
| Delete a webhook | deleteWebhook($webhook_id) |
Workflows
| Actions | Methods |
|---|---|
| List workflows | getWorkflows($options = []) |
| Fetch a workflow | getWorkflow($workflow_id) |
| Activate a workflow | activateWorkflow($workflow_id) |
| Pause a workflow | pauseWorkflow($workflow_id) |
| Start a subscriber on a workflow | addSubscriberToWorkflow($workflow_id, $options = []) |
| Remove a subscriber from a workflow | removeSubscriberFromWorkflow($workflow_id, $id_or_email) |
Workflow Triggers
| Actions | Methods |
|---|---|
| List workflow triggers | getWorkflowTriggers($workflow_id) |
| Create a workflow trigger | createWorkflowTrigger($workflow_id, $options = []) |
| Update a workflow trigger | updateWorkflowTrigger($workflow_id, $options = []) |
Contributing
- Fork it ( https://github.com/mmollick/drip-php/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Add tests when relevant
- If you add a new method to the Request class or the Request traits be sure to include the static declaration in Drip.php's phpdoc
- Push to the branch (git push origin my-new-feature)
- Fix linting issues Code-Climate Identifies
- Create a new Pull Request
Support
This package is open-source and maintained by the community. Drip does not directly participate in the maintenance of this package. Any issues with this package should be addressed by opening a new issue.
mmollick/drip-php 适用场景与选型建议
mmollick/drip-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.92k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2018 年 02 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「email」 「sdk」 「wrapper」 「drip」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mmollick/drip-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mmollick/drip-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mmollick/drip-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Extensible library for building notifications and sending them via different delivery channels.
Email+ extends Kirby's email capabilities by adding support for multiple email services using the same Kirby email API.
Laravel contact us form package to send email and save to database
A plugin for saving emails to a list
Sendy API implementation for Laravel
统计信息
- 总下载量: 10.92k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-02-07