wabel / threads-io-php-plug

此包的最新版本(dev-master)没有可用的许可证信息。

将Threads.io连接到您的PHP应用程序,并开始收集用户的活动数据。

dev-master / 1.0.x-dev 2015-09-24 03:42 UTC

This package is auto-updated.

Last update: 2024-09-06 08:58:01 UTC


README

Scrutinizer Code Quality Build Status Coverage Status

Wabel的Threads.io PHP插件

这是什么?

此项目是一个PHP连接器,用于Threads.io。使用此插件可以识别您的用户、跟踪事件和页面访问,或从您的Threads.io账户中删除他们。

初始化

以下是一个基本示例,说明您如何使用Wabel的Threads.io PHP插件

use \Wabel\ThreadsIo\ThreadsIoClient;
use \Wabel\ThreadsIo\ThreadsIoService;

// The ThreadsIoClient class is the low level class used to make the API calls.
// It takes your eventKey in parameter, which is provided to you by Threads.io
$client = new ThreadsIoClient(YOUR_EVENT_KEY);

// The ThreadsIoService class is the high level class that you will use with the Entities to make your API Calls
// It takes your fresh new ThreadsIoClient object in argument to be instantiate
$service = new ThreadsIoClient($client);

此包的两个主要组件是ThreadsIoClientThreadsIoService

ThreadsIoClient是Threads.io API的程序实现。它确保数据以API期望的格式发送。ThreadsIoService是主要的类,用于实例化和使用。它旨在使用包的实体系统,这意味着可以轻松操作用户事件页面对象。每个调用方法都期望一个实现ThreadableInterface或此包提供的实体之一的对象。

接口和实体

如前所述,ThreadsIoService操作实体。用户实体、事件实体或页面实体是您PHP应用程序中现有类的实例,分别实现了UserThreadableInterfaceEventThreadableInterfacePageThreadableInterface。例如,用于操作应用程序中用户的Member类是实现UserThreadable接口的良好候选者。如果您没有可以实现ThreadableInterfaces的类,您可以使用此包中提供的Wabel\Entities(用户、事件或页面)之一手动实例化。

use \Wabel\ThreadsIo\Entities\User;
use \Wabel\ThreadsIo\Entities\Event;
use \Wabel\ThreadsIo\Entities\Page;

// Whether you retrieve an object implementing the UserThreadableInterface from your DB...
$yourUser = $dao->getMemberById(2103);

// ...or that you create one using the provided entity class User...
$threadsIoUser = new User("ID254632", [
    "name" => "Jesus Christ",
    "company" => "Christian Church",
    "date_of_birth" => "24/12/0001",
]);

...

// ... you'll be able to use them both with the ThreadsIoService
$service->identify($yourUser);
$service->identify($threadsIoUser);

如何使用ThreadsIoService

在版本1.0.0中,我们引入了基本函数“identify”、“track”、“page”和“remove”的第一个使用。以下是对该服务的简单使用示例

use \Wabel\ThreadsIo\Entities\User;
use \Wabel\ThreadsIo\Entities\Event;
use \Wabel\ThreadsIo\Entities\Page;
use \Wabel\ThreadsIo\ThreadsIoClient;
use \Wabel\ThreadsIo\ThreadsIoService;

// Instantiate an object that implements one of the Wabel\ThreadsIo\Interfaces
// (one of the provided classes in this case)
$user = new User("4815162342", [
     "name" => "Hugo Reyes",
     "status" => "Lost",
     "other" => "Lottery winner"
 ]);

$event = new Event("New Lost Person Report", [
     "plane" => "Oceanic 815",
     "crash_location" => "Pacific Ocean"
 ]);

$page = new Page("New plane crash: Oceanic 815 on fire in the Pacific Ocean", [
     "url" => "http://www.bignews.com/New-plane-crash-Oceanic-815-on-fire-in-the-Pacific-Ocean",
     "referer" => "http://www.bignews.com",
     "time_spent_on_page" => "18s"
 ]);

// Then grab or create a ThreadsIoService object
$client = new ThreadsIoClient($eventKey);
$service = new ThreadsIoService($client);

// Your now able to :

// Identify a user
$service->identify($user);

// Track an event
$service->track($user, $event);

// Track a page view
$service->page($user, $page);

// Remove a user
$service->remove($user);

关于Threads.io

Threads.io提供一种基于用户活动和由账户管理员设置的流程规则发送“自动行为驱动电子邮件”的服务。您可以在此处咨询原始API。如果您注意到任何API更新,请随时提交任何pull请求。

关于Wabel

Wabel是欧洲食品行业的在线市场。在我们努力将我们的网络平台集成到更多和更多的网络服务中时,我们(Wabel的开发团队!)很高兴与Threads.io的社区分享我们的工作。