2010-12-02 7 views
4

Je souhaite récupérer des livres en utilisant l'API Amazon Product Advertising avec asp.net et C#. Tous les guides et les codes sont si déroutant qu'ils ne vous donnent pas une seule méthode pour rechercher les livres. Existe-t-il un seul talon pouvant être utilisé pour appeler le service et récupérer les livres en fonction de l'ISBN? merciAPI de publicité produit Amazon pour Asp.net & C#

Répondre

0

Vous pouvez télécharger un bon exemple de solution. http://aws.amazon.com/code/2480?_encoding=UTF8&queryArg=searchQuery&x=0&fromSearch=1&y=0&searchPath=code&searchQuery=Advertising

Ils vous donnent une classe appelée SignedRequestHelper, alors vous faites un appel comme celui-ci:

public static void Main() 
     { 
      SignedRequestHelper helper = new SignedRequestHelper(MY_AWS_ACCESS_KEY_ID, MY_AWS_SECRET_KEY, DESTINATION); 

      /* 
      * The helper supports two forms of requests - dictionary form and query string form. 
      */ 
      String requestUrl; 
      String title; 

      /* 
      * Here is an ItemLookup example where the request is stored as a dictionary. 
      */ 
      IDictionary<string, string> r1 = new Dictionary<string, String>(); 
      r1["Service"] = "AWSECommerceService"; 
      r1["Version"] = "2009-03-31"; 
      r1["Operation"] = "ItemLookup"; 
      r1["ItemId"] = ITEM_ID; 
      r1["ResponseGroup"] = "Small"; 

      /* Random params for testing */ 
      r1["AnUrl"] = "http://www.amazon.com/books"; 
      r1["AnEmailAddress"] = "[email protected]"; 
      r1["AUnicodeString"] = "αβγδεٵٶٷٸٹٺチャーハン叉焼"; 
      r1["Latin1Chars"] = "ĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJij"; 

      requestUrl = helper.Sign(r1); 
      title = FetchTitle(requestUrl); 

      System.Console.WriteLine("Method 1: ItemLookup Dictionary form."); 
      System.Console.WriteLine("Title is \"" + title + "\""); 
      System.Console.WriteLine(); 
} 

Vous devez utiliser le itemLookup (comme l'exemple), mais définir le IdType à ISBN. Ensuite, définissez ItemId sur l'ISBN réel. Voici les détails sur itemLookup:

docs.amazonwebservices.com/AWSECommerceService/latest/DG/index.html?ItemLookup.html

+0

Pitié il n'y a rien ItemSearchRequest dans cet exemple. – UpTheCreek

0

je reçois quand j'utilise cet échantillon. On dirait qu'il y a eu un changement dans l'API récemment.

System.InvalidOperationException: There is an error in the XML document. ---> Sy 
stem.InvalidOperationException: <ItemLookupResponse xmlns='http://webservices.am 
azon.com/AWSECommerceService/2011-08-01'> was not expected. 
0

Pour chercher des livres installer cette bibliothèque (Install-Package Nager.AmazonProductAdvertising) https://www.nuget.org/packages/Nager.AmazonProductAdvertising/

Exemple:

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

var wrapper = new AmazonWrapper(authentication, AmazonEndpoint.UK); 
//The Lord of the Rings 
var result = wrapper.Lookup("978-0261102385");