亚马逊产品广告API-C#示例 [英] Amazon product advertising api - c# sample

查看:523
本文介绍了亚马逊产品广告API-C#示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我一直在尝试使这些API示例工作三天令人沮丧。到目前为止,我仍然没有成功。我已经尝试了大约10个不同的样本,但是它们中的任何一个都不起作用。通过更多的挖掘,我发现最新的API是从2013年4月底开始,甚至最近的评论都说它起作用了。我知道实在太好了,当然我没有让它起作用。我很确定我在该程序中缺少了某些东西。

So I have been trying to get these API samples to work for three frustrating days. So far I still have had no success. I have tried about 10 different samples and of course none of them work. With some more digging the most up to date API I found was from april 2013 end even recent comments said that it worked. I knew it was just too good to be true and of course I didn't get it to work. I am pretty sure that i am missing something in that program.

这里是代码:

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请求被客户端身份验证方案'Anonymous'禁止。

I get an error: The HTTP request was forbidden with client authentication scheme 'Anonymous'.

我确实插入了 AssociateTag

这是我从以下位置下载的链接: http://dl.dropbox.com/u/119018/amazonProductAdvertisingAPI-SOAP-WCF-Updated.zip

here is the link i downloaded it from: http://dl.dropbox.com/u/119018/amazonProductAdvertisingAPI-SOAP-WCF-Updated.zip

推荐答案

一个问题可能是您没有将AccessKeyId / SecretKey放在所有必需的位置。请再次检查您的App.config并确保已设置以下内容:

One problem could be is that you didn't put your AccessKeyId/SecretKey in all the required places. Please check your App.config once again and make sure you have set the following:

  <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>
....

这篇关于亚马逊产品广告API-C#示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆