亚马逊广告 API:找不到 SignedRequestHelper 类
Posted
技术标签:
【中文标题】亚马逊广告 API:找不到 SignedRequestHelper 类【英文标题】:Amazon Advertising API: Cannot locate SignedRequestHelper class 【发布时间】:2017-10-15 20:06:16 【问题描述】:我从亚马逊暂存器获得了代码并获得了所需的包。 SignedRequestHelper 类不在包中,我无法运行该程序。我正在尝试使用 amazon asin 编号获取商品的价格。
package com.amazon.advertising.api.sample;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
/*
* This class shows how to make a simple authenticated call to the
* Amazon Product Advertising API.
*
* See the README.html that came with this sample for instructions on
* configuring and running the sample.
*/
public class lookup
/*
* Your AWS Access Key ID, as taken from the AWS Your Account page.
*/
private static final String AWS_ACCESS_KEY_ID = "XXXXXX";
/*
* Your AWS Secret Key corresponding to the above ID, as taken from the AWS
* Your Account page.
*/
private static final String AWS_SECRET_KEY = "XXXXXXX";
/*
* Use the end-point according to the region you are interested in.
*/
private static final String ENDPOINT = "webservices.amazon.com";
public static void main(String[] args)
/*
* Set up the signed requests helper.
*/
SignedRequestsHelper helper;
try
catch (Exception e)
e.printStackTrace();
return;
String requestUrl = null;
Map<String, String> params = new HashMap<String, String>();
params.put("Service", "AWSECommerceService");
params.put("Operation", "ItemLookup");
params.put("AWSAccessKeyId", "XXXXXX");
params.put("AssociateTag", "XXXXX");
params.put("ItemId", "B01H57GXUQ");
params.put("IdType", "ASIN");
params.put("ResponseGroup", "Images,ItemAttributes,Offers");
requestUrl = helper.sign(params);
System.out.println("Signed URL: \"" + requestUrl + "\"");
我将如何获得 signedrequestshelper 方法或如何更改代码?
【问题讨论】:
【参考方案1】:SignedRequestHelper 是 AWS 的代码示例之一中可用的类:
http://docs.aws.amazon.com/AWSECommerceService/latest/DG/AuthJavaSampleSig2.html
您可以复制/粘贴项目中的代码以使其运行和工作。
【讨论】:
我也遇到了这三个错误,想知道您是否可以提供帮助。谢谢错误:未报告的异常 UnsupportedEncodingException;必须被捕获或声明被抛出 byte[] secretyKeyBytes = awsSecretKey.getBytes(UTF8_CHARSET);错误:未报告的异常 NoSuchAlgorithmException;必须被捕获或声明被抛出 mac = Mac.getInstance(HMAC_SHA256_ALGORITHM);错误:未报告的异常 InvalidKeyException;必须被捕获或声明被抛出 mac.init(secretKeySpec);以上是关于亚马逊广告 API:找不到 SignedRequestHelper 类的主要内容,如果未能解决你的问题,请参考以下文章
可以通过亚马逊产品广告 API 检索 Kindle 电子书的实际价格吗?