gigabit / affilinet-php-sdk
affilinet PHP SDK,从 https://github.com/affilinet/productdata-php-sdk 分支并扩展而来
v1.0.0
2016-11-08 10:31 UTC
Requires
- php: ^5.6|^7.0
- ext-json: *
- guzzlehttp/guzzle: ~6.0
- monolog/monolog: ^1.20
- psr/http-message: *
Requires (Dev)
- apigen/apigen: ^4.1
- phpunit/phpunit: ~4.0
- vladahejda/phpunit-assert-exception: ^1.0
This package is not auto-updated.
Last update: 2024-09-30 00:37:06 UTC
README
获取 PHP SDK 并在几分钟内访问我们的 Web 服务。
这是从 官方 affilinet 产品 SDK 分支而来。它没有访问其他 Web 服务端点的可能性。
//TODO: 扩展原始文档。请参阅我们的文档以开始使用:https://affilinet.github.io/productdata-php-sdk
安装
此 SDK 可以使用 composer 安装
composer require gigabit/affilinet-php-sdk
请注意:此软件包需要 PHP 5.6 或更高版本。
示例
$config = [ 'publisher_id' => {PUBLISHER ID}, 'product_webservice_password' => {PRODUCT WEBSERVICE PASSWORD} ] $affilinet = new \Affilinet\ProductData\AffilinetClient($config); // simple search for t-shirts (using the product webservice) try { $search = new \Affilinet\ProductData\Requests\ProductsRequest($affilinet); $query = new \Affilinet\ProductData\Requests\Helper\Query(); $query->where($query->expr()->exactly('T-Shirt')); $search ->query( $query) ->onlyWithImage() ->minPrice(1) ->maxPrice(100) ->page(1) ->pageSize(20); $response = $search->send(); } catch (\Affilinet\ProductData\Exceptions\AffilinetProductWebserviceException $e) { // There is an error within your $search echo 'Error: ' . $e->getMessage(); } echo 'Total results : ' . $response->totalRecords() ; foreach ($response->getProducts() as $product) { echo $product->getProductName(); echo $product->getPriceInformation()->getDisplayPrice(); }
测试
所有测试都依赖于 composer。请在运行测试之前执行 composer install。phpunit 测试包含一些集成测试。要运行这些测试,您需要提供 publisherId 和 productWebservicePassword。将 Tests/AffilinetTestCredentials.php.dist 复制到 Tests/AffilinetTestCredentials.php 并输入您的 PUBLISHER_ID 和 PRODUCT_WEBSERVICE_PASSWORD
要仅运行单元测试,请使用此命令
phpunit --exclude-group integration
许可证
请参阅 许可证文件 了解更多信息。