是否有适用于Amazon产品API的最新c#示例?

时间:2022-10-14 03:53:09

I'm trying to create a small application that interacts with the Product API of Amazon (get prices of articles, and so on)

我正在尝试创建一个与Amazon的Product API交互的小应用程序(获取文章的价格,等等)

Unfortunately all the C# samples for the interaction with the Amazon WCF service I've found so far are outdated. I know that Amazon decided that each service call must be signed with a personal accessKeyId and secretKey, so all minimal code samples that are older than 2009 (I think they made the change in 2009) are useless. The official Amazon documentation is useless to me as well, as it does not provide necessary information.

不幸的是,到目前为止我发现的与Amazon WCF服务交互的所有C#示例都已过时。我知道亚马逊决定每个服务电话必须使用个人accessKeyId和secretKey签名,因此所有比2009年更早的代码样本(我认为他们在2009年进行了更改)都是无用的。官方的亚马逊文档对我来说也没用,因为它没有提供必要的信息。

I've also googled two tutorial on how to access the API, and following these only result in no search results for any search tearm or simply null.

我还搜索了两个关于如何访问API的教程,并且这些只会导致任何搜索范围的搜索结果或者只是null。

Is there an up-to-date (working!!) minimal sample somewhere available?

某处有可用的最新(工作!!)最小样本吗?

3 个解决方案

#1


3  

I have found a up-to-date project, the code is available on github Nager.AmazonProductAdvertising

我找到了一个最新的项目,代码可以在github Nager.AmazonProductAdvertising上找到

nuget

PM> install-package Nager.AmazonProductAdvertising

Example

var authentication = new AmazonAuthentication();
authentication.AccessKey = "accesskey";
authentication.SecretKey = "secretkey";

var wrapper = new AmazonWrapper(authentication, AmazonEndpoint.DE, "YourAssociateID");
var result = wrapper.Lookup("B0037X9N5U");

#2


2  

So, I finally found the solution, based on a comment posted here: http://www.falconwebtech.com/post/2010/06/14/Using-WCF-and-SOAP-to-Send-Amazon-Product-Advertising-API-Signed-Requests.aspx This is also the URL, where I downloaded the code I made working.

所以,我终于根据这里发表的评论找到了解决方案:http://www.falconwebtech.com/post/2010/06/14/Using-WCF-and-SOAP-to-Send-Amazon-Product-Advertising -API-Signed-Requests.aspx这也是URL,我下载了我工作的代码。

I didn't pass my "Your unique Associates ID", which I didn't even had until just now. You can get it here: https://affiliate-program.amazon.com/

我没有通过我的“你独特的员工ID”,直到现在我都没有。你可以在这里找到它:https://affiliate-program.amazon.com/

Add

itemSearch.AssociateTag = "YourAssociateID";

before amazonClient.ItemSearch(itemSearch).

Works like a charm

奇迹般有效

#3


1  

if the solution above still won't work.

如果上面的解决方案仍然无效。

try this one.. (i use microsoft visual studio 2010)

尝试这个...(我使用微软视觉工作室2010)

download the sample code on http://www.falconwebtech.com/post/2010/06/14/Using-WCF-and-SOAP-to-Send-Amazon-Product-Advertising-API-Signed-Requests.aspx

下载http://www.falconwebtech.com/post/2010/06/14/Using-WCF-and-SOAP-to-Send-Amazon-Product-Advertising-API-Signed-Requests.aspx上的示例代码

we need to update service references, make little change at app.config, program.cs, and reference.cs.

我们需要更新服务引用,在app.config,program.cs和reference.cs上做一点改动。

app.config:
(1.)
appSettings tag; assign accessKeyId and secretKey value, add
<add key="associateTag" value="yourAssociateTag" />.
(2.) behaviours tag -> endpointBehaviors tag -> behaviour tag -> signingBehavior tag; assign accessKeyId and secretKey value.
(3.) bindings tag -> basicHttpBinding tag; (optional) delete binding tag except AWSECommerceServiceBindingNoTransport and AWSECommerceServiceBindingTransport.
(4.) client tag;
delete endpoint tag except AWSECommerceServiceBindingTransport.

app.config :( 1.)appSettings标签;分配accessKeyId和secretKey值,添加 。 (2.)行为标签 - > endpointBehaviors标签 - >行为标签 - > signingBehavior标签;分配accessKeyId和secretKey值。 (3.)bindings tag - > basicHttpBinding标签; (可选)删除除AWSECommerceServiceBindingNoTransport和AWSECommerceServiceBindingTransport之外的绑定标记。 (4.)客户标签;删除除AWSECommerceServiceBindingTransport之外的端点标记。

program.cs:
add itemSearch.AssociateTag = ConfigurationManager.AppSettings["associateTag"]; before ItemSearchResponse response = amazonClient.ItemSearch(itemSearch);

program.cs:add itemSearch.AssociateTag = ConfigurationManager.AppSettings [“associateTag”];在ItemSearchResponse response = amazonClient.ItemSearch(itemSearch)之前;

reference.cs: (open file in service references folder using visual studio)
change private ImageSet[][] imageSetsField; to private ImageSet[] imageSetsField;
change public ImageSet[][] ImageSets {...} to public ImageSet[] ImageSets {...}

reference.cs :(使用visual studio在服务引用文件夹中打开文件)更改私有ImageSet [] [] imageSetsField;私人ImageSet [] imageSetsField;将public ImageSet [] [] ImageSets {...}更改为public ImageSet [] ImageSets {...}

finally we can run our program and it will work. good luck..

最后我们可以运行我们的程序,它会工作。祝你好运..

nb: there will be 1 warning (invalid child element signing behaviour), i think we can ignore it, or if you have any solution please share.. ^^v..

nb:会有1个警告(无效的子元素签名行为),我想我们可以忽略它,或者如果你有任何解决方案请分享.. ^^ v ..

#1


3  

I have found a up-to-date project, the code is available on github Nager.AmazonProductAdvertising

我找到了一个最新的项目,代码可以在github Nager.AmazonProductAdvertising上找到

nuget

PM> install-package Nager.AmazonProductAdvertising

Example

var authentication = new AmazonAuthentication();
authentication.AccessKey = "accesskey";
authentication.SecretKey = "secretkey";

var wrapper = new AmazonWrapper(authentication, AmazonEndpoint.DE, "YourAssociateID");
var result = wrapper.Lookup("B0037X9N5U");

#2


2  

So, I finally found the solution, based on a comment posted here: http://www.falconwebtech.com/post/2010/06/14/Using-WCF-and-SOAP-to-Send-Amazon-Product-Advertising-API-Signed-Requests.aspx This is also the URL, where I downloaded the code I made working.

所以,我终于根据这里发表的评论找到了解决方案:http://www.falconwebtech.com/post/2010/06/14/Using-WCF-and-SOAP-to-Send-Amazon-Product-Advertising -API-Signed-Requests.aspx这也是URL,我下载了我工作的代码。

I didn't pass my "Your unique Associates ID", which I didn't even had until just now. You can get it here: https://affiliate-program.amazon.com/

我没有通过我的“你独特的员工ID”,直到现在我都没有。你可以在这里找到它:https://affiliate-program.amazon.com/

Add

itemSearch.AssociateTag = "YourAssociateID";

before amazonClient.ItemSearch(itemSearch).

Works like a charm

奇迹般有效

#3


1  

if the solution above still won't work.

如果上面的解决方案仍然无效。

try this one.. (i use microsoft visual studio 2010)

尝试这个...(我使用微软视觉工作室2010)

download the sample code on http://www.falconwebtech.com/post/2010/06/14/Using-WCF-and-SOAP-to-Send-Amazon-Product-Advertising-API-Signed-Requests.aspx

下载http://www.falconwebtech.com/post/2010/06/14/Using-WCF-and-SOAP-to-Send-Amazon-Product-Advertising-API-Signed-Requests.aspx上的示例代码

we need to update service references, make little change at app.config, program.cs, and reference.cs.

我们需要更新服务引用,在app.config,program.cs和reference.cs上做一点改动。

app.config:
(1.)
appSettings tag; assign accessKeyId and secretKey value, add
<add key="associateTag" value="yourAssociateTag" />.
(2.) behaviours tag -> endpointBehaviors tag -> behaviour tag -> signingBehavior tag; assign accessKeyId and secretKey value.
(3.) bindings tag -> basicHttpBinding tag; (optional) delete binding tag except AWSECommerceServiceBindingNoTransport and AWSECommerceServiceBindingTransport.
(4.) client tag;
delete endpoint tag except AWSECommerceServiceBindingTransport.

app.config :( 1.)appSettings标签;分配accessKeyId和secretKey值,添加 。 (2.)行为标签 - > endpointBehaviors标签 - >行为标签 - > signingBehavior标签;分配accessKeyId和secretKey值。 (3.)bindings tag - > basicHttpBinding标签; (可选)删除除AWSECommerceServiceBindingNoTransport和AWSECommerceServiceBindingTransport之外的绑定标记。 (4.)客户标签;删除除AWSECommerceServiceBindingTransport之外的端点标记。

program.cs:
add itemSearch.AssociateTag = ConfigurationManager.AppSettings["associateTag"]; before ItemSearchResponse response = amazonClient.ItemSearch(itemSearch);

program.cs:add itemSearch.AssociateTag = ConfigurationManager.AppSettings [“associateTag”];在ItemSearchResponse response = amazonClient.ItemSearch(itemSearch)之前;

reference.cs: (open file in service references folder using visual studio)
change private ImageSet[][] imageSetsField; to private ImageSet[] imageSetsField;
change public ImageSet[][] ImageSets {...} to public ImageSet[] ImageSets {...}

reference.cs :(使用visual studio在服务引用文件夹中打开文件)更改私有ImageSet [] [] imageSetsField;私人ImageSet [] imageSetsField;将public ImageSet [] [] ImageSets {...}更改为public ImageSet [] ImageSets {...}

finally we can run our program and it will work. good luck..

最后我们可以运行我们的程序,它会工作。祝你好运..

nb: there will be 1 warning (invalid child element signing behaviour), i think we can ignore it, or if you have any solution please share.. ^^v..

nb:会有1个警告(无效的子元素签名行为),我想我们可以忽略它,或者如果你有任何解决方案请分享.. ^^ v ..