cossou/trak-io-api-client

基于Guzzle的PHP Trak.io Api客户端

v1.1.0 2015-02-16 23:15 UTC

This package is not auto-updated.

Last update: 2024-09-24 02:00:14 UTC


README

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

安装

通过Composer安装

{
    "require": {
        "cossou/trak-io-api-client": "1.0.*"
    }
}

可用方法

  • identify
  • alias
  • track
  • annotate
  • distinct_id
  • channel

文档:http://docs.trak.io/

示例

快速Identify示例

require_once 'vendor/autoload.php';

use Cossou\Trakio;

$trakio = Trakio::init('YOUR-API-TOKEN');

// or
// $trakio = Trakio::init('YOUR-API-TOKEN', array('distinct_id' => 123));

try {
    $response = $trakio->identify(array('distinct_id' => 123, 'properties' => array('name' => 'Hélder Duarte')));
    var_dump($response);
} catch(Exception $e) {
    echo $e->getMessage();
}

Laravel

将以下代码添加到app/config/app.php文件中,并滚动到提供者部分添加

'providers' => array(
    ...
    'Cossou\TrakioServiceProvider',
)

并且别名

'aliases' => array(
	...
   	'Trakio'		  => 'Cossou\Facades\Trakio',

最后,运行php artisan config:publish cossou/trak-io-api-client并填写您的API密钥。

就这样!

快速Laravel示例

Route::get('/', function()
{
	$trak = new Trakio;

	try {
		$response = $trak::identify(array('distinct_id' => 123, 'properties' => array('name' => 'Hélder Duarte')));
		dd($response);
	} catch(Exception $e) {
		dd($e->getMessage());
	}	
}

许可证

MIT许可证