aboardly / aboardly
官方Aboardly API库PHP客户端
v1.0.3
2016-05-14 20:19 UTC
Requires
- ext-json: *
- guzzle/guzzle: 3.7.*
This package is not auto-updated.
Last update: 2024-09-22 07:57:05 UTC
README
官方Aboardly API库PHP客户端
这个库是由alpaca生成,然后手动修改的,因此一些功能可能看起来有些过度设计。
安装
确保您已安装composer。
将以下内容添加到您的composer.json文件中
{ "require": { "aboardly/aboardly": "1.*" } }
更新您的依赖项
$ php composer.phar update
此包遵循其类的
PSR-0
约定命名,这意味着您可以将这些类轻松集成到自己的自动加载器中。
版本
与[ 5.4 + ]兼容
用法
<?php // This file is generated by Composer require_once 'vendor/autoload.php'; // Then we instantiate a client (as shown below)
构建客户端
未经身份验证使用此API会报错
基本身份验证
$auth = array('username' => 'api_key', 'password' => 'api_secret'); $client = new Aboardly\Client($auth);
响应信息
所有提供给API调用的回调都将接收到以下所示的响应
$response = $client->klass->method('args', $methodOptions); $response->code; // >>> 200 $response->headers; // >>> array('x-server' => 'apache')
客户API
创建/更新客户(PUT customers/:customerId)
更新客户数据。如果客户不存在,则创建。
以下参数是必需的
- customer_id:客户标识符 - 可以1:1匹配到您自己的系统中的用户。
- options.email:客户电子邮件 - 必需
- options:有关客户的数据,如first_name、last_name、email(必需)
$options = array('email' => 'test@foo.bar', 'name' => 'John Smith'); $response = $client->customers->upsert("customer_id", $options);
事件API
创建事件(POST customers/:customerId/events/:eventName)
为客户创建新事件
以下参数是必需的
- customer_id:客户标识符 - 可以1:1匹配到您自己的系统中的用户。
- event_name:事件名称(例如 logged_in、signed_up、added_funds)
$response = $events->create("customer_id", "event_name");