connect/connect-client
最新稳定版本:0.2.0
Composer 安装命令:
composer require connect/connect-client
包简介
PHP Connect SDK for interacting with the Connect API
关键字:
README 文档
README
The Connect PHP SDK allows you to push events to Connect from PHP.
If you don’t already have a Connect account, sign up here - it’s free!
Installation
The easiest way to install the Connect SDK is to use Composer.
Add connect/connect-client as a dependency and run composer update.
"require": {
…
"connect/connect-client" : "0.*"
…
}
Usage
Initializing a client
use Connect\Connect; Connect::initialize('your-project-id', 'your-push-api-key');
Pushing events
Once you have initialized Connect, you can push events easily:
$purchase = [ 'customer' => [ 'firstName' => 'Tom', 'lastName' => 'Smith' ], 'product' => '12 red roses', 'purchasePrice' => 34.95 ]; Connect::push('purchases', $purchase);
You can also push events in batches:
$batch = [ 'purchases' => [ [ 'customer' => [ 'firstName' => 'Tom', 'lastName' => 'Smith' ], 'product' => '12 red roses', 'purchasePrice' => 34.95 ], [ 'customer' => [ 'firstName' => 'Fred', 'lastName' => 'Jones' ], 'product' => '12 pink roses', 'purchasePrice' => 38.95 ] ] ]; Connect::push($batch);
Generating filtered keys
To generate a filtered key
$masterKey = 'YOUR_MASTER_KEY'; $keyDefinition = [ 'filters' => [ 'type' => 'cycling' ], 'canQuery' => True, 'canPush' => True ]; $filteredKey = Connect::generateFilteredKey($keyDefinition, $masterKey); print $filteredKey;
Exception handling
When pushing events, exceptions could be thrown, so you should either ignore or handle those exceptions gracefully.
Currently, the following exception could be thrown when pushing events:
InvalidEventException- the event being pushed is invalid (e.g. invalid event properties)
License
The SDK is released under the MIT license.
Contributing
We love open source and welcome pull requests and issues from the community!
统计信息
- 总下载量: 877
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-07-22