ecommercebox/actionml

ActionML Harness API PHP 客户端

0.9.0 2020-12-17 08:41 UTC

This package is auto-updated.

Last update: 2024-08-29 05:40:50 UTC


README

Build Status

先决条件

注意:此 SDK 仅支持 ActionML 版本 0.6 或更高。

入门

安装 ActionML PHP 客户端最简单的方法是使用 Composer

  1. actionmlPackagist 上可用,可以使用 Composer 安装。

     composer require ecommercebox/actionml
    
  2. 将 Composer 的自动加载器包含在您的 PHP 代码中

     require_once("vendor/autoload.php");
    

用法

此包是基于 Guzzle 的 Web 服务客户端。以下是一些快速示例。

实例化 ActionML API 事件客户端

use actionml\EventClient;
$engineId = 'test_ur';
$client = new EventClient($engineId, 'https://:9090');

从您的应用程序设置用户记录

// assume you have a user with user ID 5
$response = $client->setUser(5);

从您的应用程序设置项目记录

// assume you have a book with ID 'bookId1' and we assign 1 as the type ID for book
$response = $client->setItem('bookId1', array('itypes' => 1));

从您的应用程序导入用户动作(查看)

// assume this user has viewed this book item
$client->recordUserActionOnItem('view', 5, 'bookId1');

检索预测结果

// assume you have created an itemrank engine on localhost:9090
// we try to get ranking of 5 items (item IDs: 1, 2, 3, 4, 5) for a user (user ID 7)

$engineClient = new EngineClient('test_ur');
$response = $engineClient->queryItemSet(aray(7,4,6));

print_r($response);

错误和功能请求

使用 ActionML PHP SDK 问题 报告错误或请求新功能。

贡献

阅读 贡献代码 页面。

许可

Apache PredictionIO 在 Apache 2 许可证 下。