【问题标题】:Could someone provide a C# example using itemsearch from Amazon Web Services有人可以使用 Amazon Web Services 中的 itemsearch 提供一个 C# 示例吗
【发布时间】:2010-10-01 00:14:53
【问题描述】:

我正在尝试使用 Amazon Web Services 来查询艺术家和标题信息并接收专辑封面。使用 C# 我找不到任何与此类似的示例。所有在线示例都已过时,不适用于 AWS 的较新版本。

【问题讨论】:

  • 您是否曾经根据以下内容使 itemsearch 工作?我也在努力让它工作,但目前运气不佳:(
  • 也一样。运气不太好。下面选择的答案没有多大帮助。

标签: c# amazon albumart


【解决方案1】:

CodePlex 上有一个开源项目,您可能想看看......它是亚马逊网络服务的 .NET 库。 S3、SQS、FPS、EC2 和 DevPay

可以这么简单(如 codeplex 所示):

S3Client s3 = new S3Client("myAWSKey", "MyAWSPassword");

bool success = s3.Connect();

S3Client s3 = new S3Client("key", "secret"):
var buckets = from b in s3.Buckets
                           where b.Name == "demo"
                           select b;
foreach(Bucket b in buckets)
{
     Console.WriteLine(b.About());
}

【讨论】:

    【解决方案2】:

    物有所值。这是在 Asp.Net 控件中显示书籍信息的代码。您可能可以很容易地根据您的目的调整它。或者至少给你一个起点。如果您真的需要,我很乐意将控件捆绑并发送给您。

    if (!(string.IsNullOrEmpty(ISBN) && string.IsNullOrEmpty(ASIN)))
    {
        AWSECommerceService service = new AWSECommerceService();
        ItemLookup lookup = new ItemLookup();
        ItemLookupRequest request = new ItemLookupRequest();
    
        lookup.AssociateTag = ConfigurationManager.AppSettings["AssociatesTag"];
        lookup.AWSAccessKeyId = ConfigurationManager.AppSettings["AWSAccessKey"];
        if (string.IsNullOrEmpty(ASIN))
        {
            request.IdType = ItemLookupRequestIdType.ISBN;
            request.ItemId = new string[] { ISBN.Replace("-", "") };
        }
        else
        {
            request.IdType = ItemLookupRequestIdType.ASIN;
            request.ItemId = new string[] { ASIN };
        }
        request.ResponseGroup = ConfigurationManager.AppSettings["AWSResponseGroups"].Split(new char[] { ' ', ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
    
        lookup.Request = new ItemLookupRequest[] { request };
        ItemLookupResponse response = service.ItemLookup(lookup);
    
        if (response.Items.Length > 0 && response.Items[0].Item.Length > 0)
        {
            Item item = response.Items[0].Item[0];
            if (item.MediumImage == null)
            {
                bookImageHyperlink.Visible = false;
            }
            else
            {
                bookImageHyperlink.ImageUrl = item.MediumImage.URL;
            }
            bookImageHyperlink.NavigateUrl = item.DetailPageURL;
            bookTitleHyperlink.Text = item.ItemAttributes.Title;
            bookTitleHyperlink.NavigateUrl = item.DetailPageURL;
            if (item.OfferSummary.LowestNewPrice == null)
            {
                if (item.OfferSummary.LowestUsedPrice == null)
                {
                    priceHyperlink.Visible = false;
                }
                else
                {
                    priceHyperlink.Text = string.Format("Buy used {0}", item.OfferSummary.LowestUsedPrice.FormattedPrice);
                    priceHyperlink.NavigateUrl = item.DetailPageURL;
                }
            }
            else
            {
                priceHyperlink.Text = string.Format("Buy new {0}", item.OfferSummary.LowestNewPrice.FormattedPrice);
                priceHyperlink.NavigateUrl = item.DetailPageURL;
            }
            if (item.ItemAttributes.Author != null)
            {
                authorLabel.Text = string.Format("By {0}", string.Join(", ", item.ItemAttributes.Author));
            }
            else
            {
                authorLabel.Text = string.Format("By {0}", string.Join(", ", item.ItemAttributes.Creator.Select(c => c.Value).ToArray()));
            }
            ItemLink link = item.ItemLinks.Where(i => i.Description.Contains("Wishlist")).FirstOrDefault();
            if (link == null)
            {
                wishListHyperlink.Visible = false;
            }
            else
            {
                wishListHyperlink.NavigateUrl = link.URL;
            }
        }
    }
    

    【讨论】:

    • 谢谢,这个周末我得试试,现在太忙了,没时间做那个项目。
    • 只想对发布此代码表示感谢。你为我节省了几个小时
    猜你喜欢
    • 1970-01-01
    • 2021-10-31
    • 1970-01-01
    • 1970-01-01
    • 2014-05-25
    • 1970-01-01
    • 2014-06-04
    • 2012-10-25
    • 2017-09-29
    相关资源
    最近更新 更多