2010-12-02 13 views
5

का उपयोग कर अमेज़ॅन बुक सर्च एपीआई एएसपीनेट के साथ एक आईएसबीएन नंबर का उपयोग कर एक पुस्तक खोजने के लिए अमेज़ॅन एपीआई का उपयोग कैसे किया जा सकता है?एएसपीनेट

उत्तर

2

http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl ऊपर दिए गए यूआरएल के लिए एक svcutil.exe का उपयोग कर प्रॉक्सी बनाएं और फिर इस GetBookByISBN लिए विधि है। अमेज़ॅनबुक मेरा कटऑम डीटीओ है जिसे आपको अपना बनाना है।

public static AmazonBook GetBookByISBN(string ISBN) 
    { 
     WebConfigHelper wch = new WebConfigHelper("AWSSettings"); 
     AmazonBook book = null; 
     string AWSAccessKeyId = wch["AccessKey"]; 
     string AssociateTag = wch["AssociateTag"]; 
     string AWSSecKey = wch["SecretKey"]; 

     BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport); 
     binding.MaxReceivedMessageSize = int.MaxValue; 

     AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient(
      binding, 
      new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService")); 

     // add authentication to the ECS client 
     client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(AWSAccessKeyId, AWSSecKey)); 


     ItemSearchRequest request = new ItemSearchRequest(); 
     request.SearchIndex = "Books"; 
     request.Power = "ISBN:" + ISBN.Trim(); 
     request.ResponseGroup = new string[] { "Large" }; 
     request.Sort = "salesrank"; 

     ItemSearchRequest[] requests = new ItemSearchRequest[] { request }; 

     ItemSearch itemSearch = new ItemSearch(); 
     itemSearch.AWSAccessKeyId = AWSAccessKeyId; 
     itemSearch.AssociateTag = AssociateTag; 
     itemSearch.Request = requests; 


     try 
     { 
      ItemSearchResponse response = client.ItemSearch(itemSearch); 
      Items info = response.Items[0]; 
      if (info.Item != null) 
      { 
       Item[] items = info.Item; 
       if (items.Length == 1) 
       { 
        book = new AmazonBook(items[0]); 
       } 
      } 
     } 
     catch (Exception ex) 
     { 
      throw ex; 
     } 
     return book; 


    } 

reagards,

+0

यह एक WCF सेवा संदर्भ है: पुस्तकालय भी नेट स्टैंडर्ड 2.0

आप यहाँ एक asp.net Website कार्यान्वयन उदाहरण

PM> Install-Package Nager.AmazonProductAdvertising 

लघु उदाहरण मिल सकते हैं समर्थन करते हैं? मैं SOAP webservice में अधिक रुचि रखूंगा। –

+0

सहयोगी टैग? मैं एक एक्सेस कुंजी देख सकता हूं लेकिन टैग को जोड़ सकता हूं? –

+0

एसोसिएट टैग कुछ अमेज़ॅन को किसी ट्रैक को ट्रैक करने के लिए उपयोग किया जाता है जिसे अमेज़ॅन को एक निश्चित अमेज़ॅन खाते से रीडायरेक्ट किया जाता है .. अधिक जानकारी https://forums.aws.amazon.com/thread.jspa?messageID=149729 –

0

आप इस पुस्तकालय Nager.AmazonProductAdvertising उपयोग कर सकते हैं आप इसे nuget साथ आसान स्थापित कर सकते हैं।

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

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