netvlies / bol-openapi-php-sdk
Bol OpenApi SDK for PHP开发者,让您轻松在Bol OpenApi上开发产品。
v1.0.0
2012-06-06 08:15 UTC
Requires
- php: >=5.3.0
- kriswallsmith/buzz: v0.5
This package is not auto-updated.
Last update: 2024-09-22 02:42:00 UTC
README
Bol.com Open Api是一个RESTful API,您可以使用它与Bol.com网店目录进行通信。这个库使得在PHP应用程序中将此API作为服务使用变得非常简单。
您需要有一个开发者密钥来使用此API。您可以在Bol.com开发者中心注册以获得一个。
许可证
此库根据MIT许可证发布。请参阅LICENSE文件中的完整许可证。
安装
要求
PHP >=5.3.0
使用方法
// ..
$httpBrowser = new \Buzz\Browser();
$accessKey = 'ABC';
$secretAccessKey = 'DEF';
$apiClient = new Client($accessKey, $secretAccessKey, $httpBrowser);
// ..
搜索产品/类别
搜索结果操作通过提供关键词或ISBN/EAN返回产品信息。该操作具有过滤和分页选项。
// ..
$term = 'PHP';
$options = array(
'categoryIdAndRefinements' => null,
'offset' => 0,
'nrProducts' => 10,
'sortingMethod' => SortingMethod::PRICE,
'sortingAscending' => true,
'includeProducts' => true,
'includeCategories' => true,
'includeRefinements' => true
);
$searchResult = $apiClient->searchResults($term, $options);
// ..
列出产品/类别
列表结果操作根据列表类型和类别返回各种产品列表。类别基于id,可以通过类别列表请求获得。
有关可用列表类型的更多信息,请参阅文档。
// ..
$type = ProductListType::TOPLIST_DEFAULT;
$categoryIdAndRefinements = '87';
$options = array(
'offset' => null,
'nrProducts' => 10,
'sortingMethod' => SortingMethod::TITLE,
'sortingAscending' => true,
'includeProducts' => false,
'includeCategories' => true,
'includeRefinements' => true
);
$listResult = $apiClient->listResults($type, $categoryIdAndRefinements, $options);
// ..
获取产品信息
产品操作获取产品的详细信息。
// ...
$productId = '1002004011800815';
$productResponse = $apiClient->products($productId);
// ...
枚举
有关可能枚举选项的列表(例如排序方法),请参阅Enum命名空间中的类。
文档
有关API的更多文档可以在Bol.com开发者中心找到。
测试
请确保首先安装依赖项,然后在lib根目录下运行phpunit。
phpunit