ASP.NET Amazon ItemSearch

问题描述 投票:5回答:4

有没有人知道任何好的例子,或者关心如何做一个类似于这个的亚马逊查找,http://blogs.msdn.com/b/coding4fun/archive/2006/10/31/912260.aspx,我会用它,但它似乎已经过时了,而且源代码不再可用。理想我想要做的是在任何一个关键词上查找项目,例如“星际迷航”或直接UPC。我想要回来的是标题,描述,年份和图像链接,类型(DVD,书籍,音乐)。任何帮助都会很棒,谢谢。

c# asp.net amazon
4个回答
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);
}

4
投票

我写了一个小的C# Wrapper for Amazon ItemLookup,它可以为您提供一个方便的对象图。它现在只支持ItemLookup。我有源on BitBucket

你可以拨打电话:

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

1
投票

嗨,使用以下nuget Nager.AmazonProductAdvertising包很容易

掘金

PM> Install-Package Nager.AmazonProductAdvertising

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

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

© www.soinside.com 2019 - 2024. All rights reserved.