thomas-dotworx / gosquared-php-sdk
1.0.3
2015-04-27 11:56 UTC
This package is not auto-updated.
Last update: 2024-10-02 08:48:54 UTC
README
GoSquared官方PHP模块,用于轻松将GoSquared API集成到您的PHP应用程序中。
用法
跟踪API
有关完整文档,请参阅跟踪API文档网站。
报告API
报告API及其功能列在报告API文档网站上。
快速指南
require_once('gosquared-php-sdk/main.php'); $opts = array( 'site_token' => 'your-site-token', 'api_key' => 'your-api-key' ); $GS = new GoSquared($opts); // Track events $result = $GS->track_event('Event Name'); // Create anonymous Person $person = $GS->create_person(); // Identify person $response = $person->identify('user-id', array( 'name' => 'Foo Bar', 'email' => 'foo@bar.com' )); // Retrieve live data $result = $GS->now->concurrents(); // Retrieve historical data $result = $GS->trends->aggregate(); // Retrieve Ecommerce data $result = $GS->ecommerce->transactions();
要求
- PHP >= 5.2.0
- cURL
运行测试
make test
要使用自己的站点令牌和API密钥进行测试,可以在该命令前加上包含您的密钥的SITE_TOKEN和API_KEY环境变量。警告:这将跟踪测试数据到您的账户下
调试
要启用调试日志,在包含此库之前放置以下定义语句
define('GOSQUARED_DEBUG', true);
然后,调试输出将发送到标准输出流。常见的输出位置包括您的控制台(如果使用CLI运行)、您的Web服务器日志或php-fpm日志。