定制 connect/connect-client 二次开发

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

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

connect/connect-client

最新稳定版本:0.2.0

Composer 安装命令:

composer require connect/connect-client

包简介

PHP Connect SDK for interacting with the Connect API

README 文档

README

Join the chat at https://gitter.im/getconnect/connect-php

Build Status Latest Stable Version

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
  • 点击次数: 2
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固