此包的最新版本(dev-master)没有可用的许可信息。

亚马逊产品广告API

dev-master 2016-09-25 14:32 UTC

This package is auto-updated.

Last update: 2024-08-29 04:26:50 UTC


README

此库封装了以下亚马逊产品广告API的功能:

1. ItemSearch
2. BrowseNodeLookup
3. ItemLookup
4. SimilarityLookup
5. CartAdd
6. CartClear
7. CartCreate
8. CartGet
9. CartModify

用法

1. 加载并初始化 Apai 类 ```php require_once __DIR__ . '/../vendor/autoload.php'; // 使用 Composer 自动加载文件

use Edwinmugendi\Amazon\Apai;

$apai = new Apai();

2. Set the following 4 configs using the <code>$apai->setConfig()</code> function
```php
//Set configs
$apai->setConfig('ApiKey', 'XXXXX');
$apai->setConfig('ApiSecret', 'XXXX');
$apai->setConfig('AssociativeTag', 'XXXX');
$apai->setConfig('EndPoint', 'webservices.amazon.de');
  1. 如果您正在通过项目列表进行循环,您可能需要重置参数。这基本上会删除任何预设的参数
//Reset parameters first. This is important if you are looping through items
$apai->resetParam();
  1. 使用 $apai->setParam() 函数设置参数
//Set parameters
$apai->setParam('SearchIndex', 'All');
$apai->setParam('ResponseGroup', 'Offers');
$apai->setParam('Keywords', 'hp laptop');
  1. 调用实际函数,例如 ItemSearch
$verbose = true; //Print url sent to Amazon and the results from Amazon
$response = $apai->itemSearch($verbose);
  1. 处理响应。响应是一个包含 statusresponse 键的数组。如果请求成功,status 将为 1,并且 response 将包含您应该使用 SimpleXMLElement 解析的 xml 字符串,否则 status 将为 0,并且 response 将包含错误消息。
if ($response['status']) {
    $item_lookup_xml = new \SimpleXMLElement($response['response']);
} else {
    echo $response['response'];
}//E# if else statement

有关每个函数的示例代码,请检查 tests 文件夹。

如果您需要任何帮助,请通过 edwinmugendi@gmail.com 联系我。