affilinet / productdata-php-sdk
affilinet产品数据PHP SDK
v1.0.2
2017-08-10 10:30 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-28 19:52:48 UTC
README
获取我们的产品数据PHP SDK,几分钟内即可访问数百万种产品。
请参考我们的文档以开始使用:https://affilinet.github.io/productdata-php-sdk
安装
此SDK可以通过composer安装
composer require affilinet/productdata-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
许可证
有关更多信息,请参阅许可证文件。