所以我一直试图让这些API样本在三个令人沮丧的日子里工作.到目前为止,我仍然没有成功.我尝试了大约10种不同的样品,当然没有一种可以使用.随着更多挖掘最新的API我发现是从2013年4月结束,甚至最近的评论说它有效.我知道这真是太好了,当然我没有让它发挥作用.我很确定我错过了该计划中的一些内容.
这是代码:
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();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:HTTP请求被禁止使用客户端身份验证方案"Anonymous".
我确实插入了AssociateTag值和访问密钥ID但仍然给出了相同的结果.
这是我下载的链接:http://dl.dropbox.com/u/119018/amazonProductAdvertisingAPI-SOAP-WCF-Updated.zip
小智 7
一个问题可能是您没有将AccessKeyId/SecretKey放在所有必需的位置.请再次检查您的App.config并确保已设置以下内容:
<appSettings>
<add key="amazonSecurityNamespace" value="http://security.amazonaws.com/doc/2007-01-01/" />
<add key="accessKeyId" value="**{put your Id here}**" />
<add key="secretKey" value="**{put your key here}**" />
</appSettings>
<system.serviceModel>
<extensions>
<behaviorExtensions>
<add name="signingBehavior" type="Amazon.PAAPI.WCF.AmazonSigningBehaviorExtensionElement, Amazon.PAAPI.WCF, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</behaviorExtensions>
</extensions>
<behaviors>
<endpointBehaviors>
<behavior name="amazonEndpointBehavior">
<signingBehavior accessKeyId="**{put your Id here}**" secretKey="**{put your key here}**" />
</behavior>
</endpointBehaviors>
</behaviors>
....
Run Code Online (Sandbox Code Playgroud)