누군가 Amazon Web Services에서 itemsearch를 사용하여 C# 예제를 제공 할 수 있습니까?

StackOverflow https://stackoverflow.com/questions/436801

  •  22-07-2019
  •  | 
  •  

문제

Amazon Web Services를 사용하여 아티스트와 제목 정보를 쿼리하고 앨범 Art Back을 받으려고합니다. C#을 사용하면 이것에 가까운 예제를 찾을 수 없습니다. 온라인으로 모든 예제는 구식이며 AWS의 최신 버전에서는 작동하지 않습니다.

도움이 되었습니까?

해결책

여기에서 당신은 그 가치가있는 것을 위해 간다. 이것은 책 정보를 표시하기 위해 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;
        }
    }
}

다른 팁

오픈 소스 프로젝트가 있습니다 코드 플렉스 Amazon 웹 서비스를위한 .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());
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top