2011-01-21 6 views
5

誰かが良い例を知っていますか、これに似たアマゾン検索を行う方法を説明するのに気をつけてください、http://blogs.msdn.com/b/coding4fun/archive/2006/10/31/912260.aspx、私はちょうどこれを使用しますが、古くなっていると思われます。利用できない。理想私がしたいと思うのは、「スタートレック」やまっすぐなUPCのようなキーワードの項目を探すことです。私が取り戻したいのは、タイトル、説明、年、画像へのリンク、タイプ(DVD、書籍、音楽)です。どんな助けも素晴らしいだろう、ありがとう。 Amazonのウェブサイト上の例のセット全体ありますASP.NET Amazon ItemSearch

答えて

1

は、.NET用SprightlySoft AWSコンポーネントを使用すると、対話する意志Amazonの商品広告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"); 
関連する問題