malong/productai

此包已被废弃且不再维护。没有建议的替代包。

ProductAI 的官方 PHP SDK。

1.0.5 2018-06-08 00:00 UTC

README

Latest Stable Version License Travis CI Build Status Code Coverage

ProductAI® SDKs 允许您轻松地在您选择的编程语言中使用 ProductAI® API。您可以使用我们的 PHP SDK 发送图像查询并维护您的数据集。

安装

composer require malong/productai

版本

1.0.0 和 0.4.0 之间存在重大更改。

  • 1.0.0 中的对象模型更好。每个功能都封装在一个专门的类中。这避免了 0.4.0 中的超级大类。

兼容性

所有新功能都将添加到 src/APIsrc/Core 目录中,这两个目录包含 1.0.0 版本的代码。这些目录下的所有类都使用新的命名空间 ProductAI\APIProductAI\Core。如果您想使用新功能,请使用命名空间 ProductAI\API 下的类,而不是 ProductAI

从现在起,将不再向 src/API.phpsrc/Base.phpsrc/ProductSetApi.phpsrc/SearchApi.phpsrc/SearchServiceMananagementApi.php 添加任何更改。考虑到兼容性,我们将保留这些代码。升级到 1.0.0 后,您可以使用新功能而无需修改任何现有代码。

测试

创建一个名为 tests/config.inc.php 的文件,并定义以下常量

<?php

// get this key from https://console.productai.cn
define('ACCESS_KEY_ID', '');

// get this key from https://console.productai.cn
define('SECRET_KEY', '');

// this prefix is attached to any object name and description.
// then you can easily recognize those objects generated in test cases (
// usually test will automatically clean it, just in case you need manually clean it)
define('TEST_PREFIX', '');

// you must prepare a running image search service before running tests
define('IMAGE_SEARCH_SERVICE_ID', "");

// you must prepare a running product search service before running tests
define('PRODUCT_SEARCH_SERVICE_ID', "");

运行测试

composer self-update
composer install -n
vendor/bin/phpunit --bootstrap=tests/config.inc.php tests/

使用

请阅读 ProductAI 开发者文档

中文说明

ProductAI® SDK 提供了 API 请求封装与签名验证功能,用户可以轻松使用 PHP SDK 完成 API 的调用。

安装

推荐中国大陆用户使用国内镜像

composer require malong/productai

版本

从 0.4.0 到 1.0.0 是一个 Breaking Change。主要区别:

  • 1.0.0 中使用更好的对象模型来封装 ProductAI API。每个功能都单独分离到一个独立的类中。避免了 0.4.0 中的超级大类。

兼容性说明

所有新功能都将添加到 src/APIsrc/Core 目录中。这两个目录包含 1.0.0 版本的代码。这些目录下的所有类都使用新的命名空间 ProductAI\APIProductAI\Core。如果您想使用新功能,请使用命名空间 ProductAI\API 下的类。

今后,除了 bug fix,将不再对以下文件进行调整:src/API.phpsrc/Base.phpsrc/ProductSetApi.phpsrc/SearchApi.phpsrc/SearchServiceMananagementApi.php。但是考虑到兼容性,将一直保留这些代码。这样您可以在升级到 1.0.0 后使用新功能,而无需对现有代码进行任何修改。

测试

创建文件 tests/config.inc.php 并定义如下常量:

<?php

// get this key from https://console.productai.cn
define('ACCESS_KEY_ID', '');

// get this key from https://console.productai.cn
define('SECRET_KEY', '');

// this prefix is attached to any object name and description.
// then you can easily recognize those objects generated in test cases (
// usually test will automatically clean it, just in case you need manually clean it)
define('TEST_PREFIX', '');

// you must prepare a running image search service before running tests
define('IMAGE_SEARCH_SERVICE_ID', "");

// you must prepare a running product search service before running tests
define('PRODUCT_SEARCH_SERVICE_ID', "");

运行测试:

composer self-update
composer install -n
vendor/bin/phpunit --bootstrap=tests/config.inc.php tests/

使用

请阅读 ProductAI 开发者文档