【发布时间】:2013-11-04 10:38:49
【问题描述】:
因此,我一直在努力让这些 API 示例运行三天,令人沮丧。到目前为止,我仍然没有成功。我尝试了大约 10 种不同的样品,当然它们都不起作用。随着一些更多的挖掘,我发现最新的 API 是从 2013 年 4 月开始,甚至最近的 cmets 都说它有效。我知道这太好了,不可能是真的,当然我没有让它发挥作用。我很确定我在那个程序中遗漏了一些东西。
代码如下:
namespace Amazon.PAAPI
{
class Program
{
static void Main(string[] args)
{
// Instantiate Amazon ProductAdvertisingAPI client
AWSECommerceServicePortTypeClient amazonClient = new AWSECommerceServicePortTypeClient();
// prepare an ItemSearch request
ItemSearchRequest request = new ItemSearchRequest();
request.SearchIndex = "Books";
request.Title = "WCF";
request.ResponseGroup = new string[] { "Small" };
ItemSearch itemSearch = new ItemSearch();
itemSearch.Request = new ItemSearchRequest[] { request };
itemSearch.AWSAccessKeyId = ConfigurationManager.AppSettings["accessKeyId"];
itemSearch.AssociateTag = "ReplaceWithYourValue";
// send the ItemSearch request
ItemSearchResponse response = amazonClient.ItemSearch(itemSearch);
// write out the results from the ItemSearch request
foreach (var item in response.Items[0].Item)
{
Console.WriteLine(item.ItemAttributes.Title);
}
Console.WriteLine("done...enter any key to continue>");
Console.ReadLine();
}
}
}
我收到一个错误:HTTP 请求被客户端身份验证方案“匿名”禁止。
我确实插入了 AssociateTag 值和访问密钥 ID,但它仍然给出了相同的结果。
这是我下载的链接:http://dl.dropbox.com/u/119018/amazonProductAdvertisingAPI-SOAP-WCF-Updated.zip
【问题讨论】:
-
您注册了亚马逊网络服务吗?我想您需要指定 Amazon api 密钥..
-
是的,我有。在网络服务和亚马逊员工中都有
-
为了你想做的事;您是否指定了两个 api 密钥?亚马逊很少(如果有的话)允许匿名 api 请求。上面还有一个 AssociateTag 占位符,看起来您需要用与您的情况相关的值替换。
-
是的,我已经替换了 associateTag 的值。我知道我的 api 键值,并且我已将这些值插入到每个样本中,包括这个。