Question

I am trying to use Amazon Web Services to query Artist and title information and receive album art back. Using C# I cannot find any examples that come even close to this. All of the examples online are outdated and do not work with AWS' newer version.

Was it helpful?

Solution

Here you go for what it's worth. This is code within an Asp.Net control to display book information. You can probably adapt it for your purposes easily enough. Or at least give you a starting-point. If you really want, I'd be happy to bundle the control up and send it your way.

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;
        }
    }
}

OTHER TIPS

There is an open Source project on CodePlex you might want to take a look at.... It's A .NET Library for Amazon's Web Services. S3, SQS, FPS, EC2, and DevPay

It could be as simple as this(as shown on 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());
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top