يمكن أن توفر شخص ما C # المثال باستخدام itemsearch من خدمات ويب الأمازون

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

  •  22-07-2019
  •  | 
  •  

سؤال

وأنا أحاول أن استخدام خدمات ويب الأمازون الاستعلام الفنان وعنوان المعلومات وتلقي الألبوم الظهر. باستخدام 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;
        }
    }
}

نصائح أخرى

وهناك مشروع مفتوح المصدر على كود بلاكس الذي قد ترغب في إلقاء نظرة على ... . انها وNET مكتبة لخدمات ويب الأمازون. S3، SQS، FPS، EC2، وDevPay

ويمكن أن تكون بسيطة مثل هذا (كما هو موضح على كود بلاكس):

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