I'm trying to create a small application that interacts with the Product API of Amazon (get prices of articles, and so on)
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.
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.
Is there an up-to-date (working!!) minimal sample somewhere available?
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");
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
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..