Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Asp.net的亚马逊图书搜索API_Asp.net_Json_Asp.net Ajax_Amazon Web Services - Fatal编程技术网

使用Asp.net的亚马逊图书搜索API

使用Asp.net的亚马逊图书搜索API,asp.net,json,asp.net-ajax,amazon-web-services,Asp.net,Json,Asp.net Ajax,Amazon Web Services,如何使用AmazonAPI在asp.net中使用ISBN号搜索图书? 使用svcutil.exe为上述给定url创建代理 然后这就是获取BookByISBN的方法。AmazonBook是我的最爱,你必须自己创造 public static AmazonBook GetBookByISBN(string ISBN) { WebConfigHelper wch = new WebConfigHelper("AWSSettings"); AmazonBook b

如何使用AmazonAPI在asp.net中使用ISBN号搜索图书?

使用svcutil.exe为上述给定url创建代理 然后这就是获取BookByISBN的方法。AmazonBook是我的最爱,你必须自己创造

public static AmazonBook GetBookByISBN(string ISBN)
    {
        WebConfigHelper wch = new WebConfigHelper("AWSSettings");
        AmazonBook book = null;
        string AWSAccessKeyId = wch["AccessKey"];
        string AssociateTag = wch["AssociateTag"];
        string AWSSecKey = wch["SecretKey"];

        BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
        binding.MaxReceivedMessageSize = int.MaxValue;

        AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient(
            binding,
            new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));

        // add authentication to the ECS client
        client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(AWSAccessKeyId, AWSSecKey));


        ItemSearchRequest request = new ItemSearchRequest();
        request.SearchIndex = "Books";
        request.Power = "ISBN:" + ISBN.Trim();
        request.ResponseGroup = new string[] { "Large" };
        request.Sort = "salesrank";

        ItemSearchRequest[] requests = new ItemSearchRequest[] { request };

        ItemSearch itemSearch = new ItemSearch();
        itemSearch.AWSAccessKeyId = AWSAccessKeyId;
        itemSearch.AssociateTag = AssociateTag;
        itemSearch.Request = requests;


        try
        {
            ItemSearchResponse response = client.ItemSearch(itemSearch);
            Items info = response.Items[0];
            if (info.Item != null)
            {
                Item[] items = info.Item;
                if (items.Length == 1)
                {
                    book = new AmazonBook(items[0]);
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
        return book;


    }
Reagards,

您可以使用此库,您可以使用nuget轻松安装。该库还支持.NET标准2.0

您可以在这里找到一个实现示例

PM> Install-Package Nager.AmazonProductAdvertising
简短示例:

var authentication = new AmazonAuthentication();
authentication.AccessKey = "accesskey";
authentication.SecretKey = "secretkey";

var wrapper = new AmazonWrapper(authentication, AmazonEndpoint.US);
//The Lord of the Rings
var result = wrapper.Lookup("978-0261102385");

这是wcf服务参考?我会对SOAP-webservice更感兴趣?我可以看到一个访问密钥,但关联标签?关联标签是亚马逊用来跟踪用户的东西,从某个亚马逊帐户重定向到亚马逊。。可以在wsdl中找到更多关于btw服务的信息,您也可以将其作为复古web服务使用。