predictionio / predictionio
此包已被放弃,不再维护。未建议替代包。
Apache PredictionIO API PHP客户端
v0.13.0
2018-09-13 22:37 UTC
Requires
- php: >=5.6.0
- guzzlehttp/guzzle: ^6.1
Requires (Dev)
- apigen/apigen: ^4.1.2
- phpunit/phpunit: ^5
- symfony/class-loader: ^2.3
This package is not auto-updated.
Last update: 2021-03-19 20:48:42 UTC
README
先决条件
- PHP 5.6+ (https://php.ac.cn/)
- PHP: cURL (https://php.ac.cn/manual/en/book.curl.php)
- Phing (http://www.phing.info/)
- ApiGen (http://apigen.org/)
注意:此SDK仅支持Apache PredictionIO版本0.8.2或更高版本。
入门
安装PredictionIO PHP客户端最简单的方法是使用Composer。
-
predictionio
可在Packagist上找到,并可以使用Composer进行安装composer require predictionio/predictionio
-
在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报告错误或请求新功能。
社区
跟踪开发和社区新闻。
- 订阅用户邮件列表和开发者邮件列表。
- 关注@PredictionIO在Twitter上的动态。
贡献
阅读贡献代码页面。
许可
Apache PredictionIO遵循Apache 2许可。