predictionio/predictionio

此包已被放弃,不再维护。未建议替代包。

Apache PredictionIO API PHP客户端

v0.13.0 2018-09-13 22:37 UTC

README

Build Status

先决条件

注意:此SDK仅支持Apache PredictionIO版本0.8.2或更高版本。

入门

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

  1. predictionio可在Packagist上找到,并可以使用Composer进行安装

     composer require predictionio/predictionio
    
  2. 在PHP代码中包含Composer的自动加载器

     require_once("vendor/autoload.php");
    

用法

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

实例化PredictionIO API事件客户端

use predictionio\EventClient;
$accessKey = 'j4jIdbq59JsF2f4CXwwkIiVHNFnyNvWXqMqXxcIbQDqFRz5K0fe9e3QfqjKwvW3O';
$client = new EventClient($accessKey, 'https://:7070');

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

// 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:8000
// we try to get ranking of 5 items (item IDs: 1, 2, 3, 4, 5) for a user (user ID 7)

$engineClient = new EngineClient('https://:8000');
$response = $engineClient->sendQuery(array('uid'=>7, 'iids'=>array(1,2,3,4,5)));

print_r($response);

错误和功能请求

使用Apache JIRA报告错误或请求新功能。

社区

跟踪开发和社区新闻。

贡献

阅读贡献代码页面。

许可

Apache PredictionIO遵循Apache 2许可