定制 databreakers/php-data-api-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

databreakers/php-data-api-client

Composer 安装命令:

composer require databreakers/php-data-api-client

包简介

PHP client for DataBreakers DataAPI.

README 文档

README

This library provides PHP implementation of client for DataBreakers DataAPI.

Requirements

Library requires PHP version 5.4 (or higher) and Guzzle.

Installation

The best way to install it is using the Composer:

$ composer require databreakers/php-data-api-client

Quickstart

use DataBreakers\DataApi;

// Create a new instance of Client and provide your credentials
$client = new DataApi\Client('yourAccountId', 'yourSecretKey');

// Define items attributes (do this only when items attributes aren't defined in recommender yet)
$client->addItemsAttribute('title', DataApi\DataType::TEXT, 'en', DataApi\MetaType::TITLE);
$client->addItemsAttribute('color', DataApi\DataType::TEXT, 'en');
$client->addItemsAttribute('weight', DataApi\DataType::INTEGER);

// Add some items (if you are adding multiple items, users or interactions it's much faster to use batches)
$itemsBatch = (new DataApi\Batch\EntitiesBatch())
	->addEntity('fridgeId', [
		'title' => 'Fridge',
		'color' => 'white',
		'weight' => 55
	])
	->addEntity('carId', [
		'title' => 'Car',
		'color' => 'blue',
		'weight' => 1547
	]);
$client->insertOrUpdateItems($itemsBatch);

// Define users attributes (do this only when users attributes aren't defined in recommender yet)
$client->addUsersAttribute('name', DataApi\DataType::TEXT, 'en', DataApi\MetaType::TITLE);
$client->addUsersAttribute('age', DataApi\DataType::INTEGER);

// Add some users
$usersBatch = (new DataApi\Batch\EntitiesBatch())
	->addEntity('johnId', [
		'name' => 'John Smith',
		'age' => 35
	])
	->addEntity('sophiaId', [
		'name' => 'Sophia White',
		'age' => 27
	]);
$client->insertOrUpdateUsers($usersBatch);

// Add interactions between users and items
$interactionsBatch = (new DataApi\Batch\InteractionsBatch())
	->addInteraction('johnId', 'carId', 'Like')
	->addInteraction('johnId', 'carId', 'Purchase')
	->addInteraction('johnId', 'fridgeId', 'Dislike')
	->addInteraction('sophiaId', 'carId', 'Detail view')
	->addInteraction('sophiaId', 'fridgeId', 'Purchase');
$client->insertInteractions($interactionsBatch);

// And finally obtain ten recommendations for Sophia and car item!
$recommendations = $client->getRecommendations('sophiaId', 'carId', 10);

// If you want to send more recommendation requests at once, you can use recommendations batch
$batchRecommendations = $client->getRecommendationsBatch((new DataApi\Batch\RecommendationsBatch())
	->requestRecommendations('req1', 10, 'johnId', 'fridgeId', 20)
	->requestRecommendationsForUser('req2', 5, 'sophiaId', 15)
	->requestRecommendationsForItem('req3', 1, 'fridgeId', 10)
);

DataBreakers – we are your data sense

统计信息

  • 总下载量: 25.32k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-11-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固