2011-01-21 3 views
5

누구든지 좋은 예제를 알고 있거나 http://blogs.msdn.com/b/coding4fun/archive/2006/10/31/912260.aspx과 비슷한 아마존 조회를 수행하는 방법을 설명하는 데 신경 쓰지는 않겠지 만 오래된 것으로 보이며 소스가 있습니다. 더 이상 사용할 수 없습니다. 이상적 "Star Trek"이나 똑바로 올라가는 UPC와 같은 키워드에서 항목을 찾아 볼 수 있기를 바랍니다. 다시 돌아가고 싶은 것은 제목, 설명, 연도 및 이미지 (dvd, books, music)에 대한 링크입니다. 어떤 도움이라도 좋을 것입니다.ASP.NET Amazon ItemSearch

답변

1

.NET에 대한 SprightlySoft AWS 구성 요소는 것 아마존의 제품 광고 API를 상호 작용할 수 있습니다가. 다음은 UPC를 기반으로 항목을 찾는 샘플 코드입니다. 무료로 구성 요소를 http://sprightlysoft.com/에 가져옵니다. 구성 요소에는 Product Advertising API로 ItemSearch를 수행하는 방법을 보여주는 샘플 코드가 제공됩니다.

//Product Advertising API, ItemLookup: http://docs.amazonwebservices.com/AWSECommerceService/2010-10-01/DG/ItemLookup.html 

SprightlySoftAWS.REST MyREST = new SprightlySoftAWS.REST(); 

String RequestURL; 
RequestURL = "https://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&Operation=ItemLookup&Version=2010-10-01"; 
RequestURL += "&AWSAccessKeyId=" + System.Uri.EscapeDataString(TextBoxAWSAccessKeyId.Text) + "&SignatureVersion=2&SignatureMethod=HmacSHA256&Timestamp=" + Uri.EscapeDataString(DateTime.UtcNow.ToString("yyyy-MM-dd\\THH:mm:ss.fff\\Z")); 
RequestURL += "&ItemId=025192022272"; 
RequestURL += "&IdType=UPC"; 
RequestURL += "&SearchIndex=DVD"; 

String RequestMethod; 
RequestMethod = "GET"; 

String SignatureValue; 
SignatureValue = MyREST.GetSignatureVersion2Value(RequestURL, RequestMethod, "", TextBoxAWSSecretAccessKey.Text); 

RequestURL += "&Signature=" + System.Uri.EscapeDataString(SignatureValue); 

Boolean RetBool; 
RetBool = MyREST.MakeRequest(RequestURL, RequestMethod, null); 
System.Diagnostics.Debug.Print(MyREST.LogData); 

if (RetBool == true) 
{ 
    String ResponseMessage = ""; 
    System.Xml.XmlDocument MyXmlDocument; 
    System.Xml.XmlNamespaceManager MyXmlNamespaceManager; 
    System.Xml.XmlNode MyXmlNode; 
    System.Xml.XmlNodeList MyXmlNodeList; 

    MyXmlDocument = new System.Xml.XmlDocument(); 
    MyXmlDocument.LoadXml(MyREST.ResponseString); 

    MyXmlNamespaceManager = new System.Xml.XmlNamespaceManager(MyXmlDocument.NameTable); 
    MyXmlNamespaceManager.AddNamespace("amz", "http://webservices.amazon.com/AWSECommerceService/2010-10-01"); 

    MyXmlNodeList = MyXmlDocument.SelectNodes("amz:ItemLookupResponse/amz:Items/amz:Item", MyXmlNamespaceManager); 

    if (MyXmlNodeList.Count == 0) 
    { 
     ResponseMessage = "Item not found."; 
    } 
    else 
    { 
     foreach (System.Xml.XmlNode ItemXmlNode in MyXmlNodeList) 
     { 
      MyXmlNode = ItemXmlNode.SelectSingleNode("amz:ItemAttributes/amz:Title", MyXmlNamespaceManager); 
      ResponseMessage += "Title = " + MyXmlNode.InnerText; 

      ResponseMessage += Environment.NewLine; 
     } 
    } 

    MessageBox.Show(ResponseMessage); 
} 
else 
{ 
    MessageBox.Show(MyREST.ResponseStringFormatted); 
} 
+0

아마존이 한 번에 10 개 이상의 항목을 반환하도록하는 방법이 있는지 알고 계십니까? – nagates

+0

정보는 문서에 있습니다. http://docs.amazonwebservices.com/AWSECommerceService/2010-10-01/DG/index.html?ItemLookup.html을 참조하십시오. 각 ItemLookup 요청은 최대 10 개의 관련 항목을 반환 할 수 있습니다. – Anton

+0

이러한 문자열 연결은 조금 고약합니다. – UpTheCreek

4

약간의 쓸데없는 객체 그래프를 돌려주는 C# Wrapper for Amazon ItemLookup을 작성했습니다. 지금은 ItemLookup 만 지원합니다. 나는 소스가 on BitBucket입니다.

var item = client.LookupByAsin("B0037X9N5U"); 
double? price = item.GetLowestPrice(); 
1

안녕하세요는 다음 nuget Nager.AmazonProductAdvertising 패키지

nuget

PM> Install-Package Nager.AmazonProductAdvertising 

012 매우 간단합니다 :

당신은 같은 통화를 할 수 있습니다

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

var wrapper = new AmazonWrapper(authentication, AmazonEndpoint.DE); 
var result = wrapper.Lookup("B0037X9N5U"); 
관련 문제