简体   繁体   English

亚马逊产品广告C#API

[英]Amazon Product advertising c# api

Hi guys I'm having trouble fetching products from amazon web api. 嗨,大家好,我在从Amazon Web API获取产品时遇到了麻烦。

I have used this code from the internet, adding all the neccessary references. 我已经从互联网上使用了此代码,并添加了所有必要的参考。 I tried adding a view and chose itemsearchresponce as the model class but it does not display the product, I get the following error: 我尝试添加视图,并选择itemsearchresponce作为模型类,但是它不显示产品,出现以下错误:

Unable to generate a temporary class (result=1). 无法生成临时类(结果= 1)。 error CS0029: Cannot implicitly convert type 'AmazonProduct.com.amazon.webservices.ImageSet' to 'AmazonProduct.com.amazon.webservices.ImageSet[]' 错误CS0029:无法将类型'AmazonProduct.com.amazon.webservices.ImageSet'隐式转换为'AmazonProduct.com.amazon.webservices.ImageSet []'

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using AmazonProduct.com.amazon.webservices;
namespace Forest.Controllers
{
    public class AmazonController : Controller
    {
        private AmazonProduct.com.amazon.webservices.AWSECommerceService _Products;

        public AmazonController()
        {
            _Products = new AmazonProduct.com.amazon.webservices.AWSECommerceService();
        }

        [HttpGet]
        public ActionResult  listProducts()
        {
            var searchIndex = "Shoes";
            var keywords = "jordan";
            // Create an ItemSearch wrapper
            ItemSearch search = new ItemSearch();
            search.AssociateTag = "[Your Associate ID]";
            search.AWSAccessKeyId = "MyKey";
            // search.Version= "2011-08-01";

            // Create a request object
            ItemSearchRequest request = new ItemSearchRequest();

            // Fill the request object with request parameters
            request.ResponseGroup = new string[] { "ItemAttributes" };

            // Set SearchIndex and Keywords
            request.SearchIndex = searchIndex;
            request.Keywords = keywords;

            // Set the request on the search wrapper
            search.Request = new ItemSearchRequest[] { request };

            ItemSearchResponse response = _Products.ItemSearch(search);

            return View(response);
        }
    }
}

Go to the generated proxy and replace ImageSet[][] with ImageSet[] . 转到生成的代理,然后将ImageSet[][]替换为ImageSet[]
Also take a look at Amazon Product Advertising API C# if you already haven't. 如果还没有的话,还可以看看Amazon Product Advertising API C#

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM