Is there an up-to-date c# sample for the Amazon product API?

烂漫一生 提交于 2019-12-03 13:34:00

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.

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/

Add

itemSearch.AssociateTag = "YourAssociateID";

before amazonClient.ItemSearch(itemSearch).

Works like a charm

I have found a up-to-date project, the code is available on 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");
ardyfajarai

if the solution above still won't work.

try this one.. (i use microsoft visual studio 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

we need to update service references, make little change at app.config, program.cs, and 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.

program.cs:
add itemSearch.AssociateTag = ConfigurationManager.AppSettings["associateTag"]; before 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 {...}

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!