Example #1
1
        private static void ItemSearch()
        {
            // Create the request object
            ItemSearchRequest request = new ItemSearchRequest();

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

            // Set SearchIndex to All and use the scanned EAN
            // as the keyword, this should generate a single response
            request.SearchIndex = "Books";
            request.Keywords = "Century rain"; // asin = 0441013074
            request.Author = "Alastair Reynolds";

            // Make the item search
            ItemSearch search = new ItemSearch();

            // It is ABSOLUTELY CRITICAL that you change
            // the AWSAccessKeyID to YOUR uniqe value
            // Signup for an account (and AccessKeyID) at http://aws.amazon.com/
            search.AWSAccessKeyId = access_key_id;
            search.AssociateTag = associate_tag;

            // Set the request on the search wrapper - multiple requests
            // can be submitted on one search
            search.Request = new ItemSearchRequest[] { request };

            // Make the port
            AWSECommerceServicePortTypeClient port = new AWSECommerceServicePortTypeClient("AWSECommerceServicePort");
            port.ChannelFactory.Endpoint.EndpointBehaviors.Add(new AmazonSigningEndpointBehavior(access_key_id, secret_access_key));

            //Send the request, store the response and display some of the results
            ItemSearchResponse response = port.ItemSearch(search);

            foreach (var items in response.Items)
            {
                foreach (var item in items.Item)
                {
                    Console.WriteLine("{0}\t{1}\t{2}", item.ItemAttributes.Title, item.ASIN, item.ItemAttributes.Author[0]);

                    if (item.AlternateVersions != null)
                    {
                        Console.WriteLine(" - Alternate versions");
                        foreach (var version in item.AlternateVersions)
                        {
                            Console.WriteLine(" -- \t{0}\t{1}\t{2}", version.Title, version.Binding, version.ASIN);
                        }
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Gets a list of <seealso cref="Items"/> objects based on a list of ASIN strings.
        /// </summary>
        /// <param name="asinList">The list of ASIN strings.</param>
        /// <returns>A list of <seealso cref="Items"/> </returns>
        public static IEnumerable <Items> GetItemsFromAsinList(IList <string> asinList)
        {
            var basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);

            basicHttpBinding.MaxReceivedMessageSize = int.MaxValue;

            var associateUrl    = ConfigurationManager.AppSettings["AssociateUrl"];
            var accessKeyId     = ConfigurationManager.AppSettings["AccessKeyId"];
            var associateSecret = ConfigurationManager.AppSettings["AssociateSecret"];
            var associateTag    = ConfigurationManager.AppSettings["AssociateTag"];

            using (var awseCommerceServicePortTypeClient = new AWSECommerceServicePortTypeClient(basicHttpBinding, new EndpointAddress(associateUrl)))
            {
                var amazonEndpointBehavior = new AmazonSigningEndpointBehavior(accessKeyId, associateSecret);
                awseCommerceServicePortTypeClient.ChannelFactory.Endpoint.Behaviors.Add(amazonEndpointBehavior);

                var itemLookupRequest = new ItemLookupRequest();
                itemLookupRequest.ItemId        = asinList.ToArray();
                itemLookupRequest.ResponseGroup = new string[] { "ItemAttributes", "Images", "Offers" };

                var itemLookup = new ItemLookup();
                itemLookup.AssociateTag   = associateTag;
                itemLookup.AWSAccessKeyId = accessKeyId;
                itemLookup.Request        = new ItemLookupRequest[] { itemLookupRequest };

                var itemLookupResponse = awseCommerceServicePortTypeClient.ItemLookup(itemLookup);
                var itemArray          = itemLookupResponse.Items;

                return(itemArray.Cast <Items>());
            }
        }
Example #3
0
        public string ReviewsFrame()
        {
            BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);

            binding.MaxReceivedMessageSize = int.MaxValue;
            binding.MaxBufferSize          = int.MaxValue;

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

            // add authentication to the ECS client
            amazonClient.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(ConfigurationManager.AppSettings["accessKeyId"], ConfigurationManager.AppSettings["secretKey"]));

            ItemLookupRequest request = new ItemLookupRequest();

            request.ItemId        = this.ItemIds;
            request.IdType        = ItemLookupRequestIdType.ASIN;
            request.ResponseGroup = new string[] { "Reviews" };

            ItemLookup itemLookup = new ItemLookup();

            itemLookup.Request        = new ItemLookupRequest[] { request };
            itemLookup.AWSAccessKeyId = ConfigurationManager.AppSettings["accessKeyId"];
            itemLookup.AssociateTag   = ConfigurationManager.AppSettings["associateTag"];

            ItemLookupResponse response = amazonClient.ItemLookup(itemLookup);
            string             frameUrl = response.Items[0].Item[0].CustomerReviews.IFrameURL;

            return(frameUrl);
        }
Example #4
0
        static void Main(string[] args)
        {
            // Instantiate Amazon ProductAdvertisingAPI client
            AWSECommerceServicePortTypeClient amazonClient = new AWSECommerceServicePortTypeClient();

            // prepare an ItemSearch request
            ItemSearchRequest request = new ItemSearchRequest
            {
                SearchIndex   = "Books",
                Title         = "WCF",
                ResponseGroup = new[] { "Small" }
            };

            ItemSearch itemSearch = new ItemSearch
            {
                Request        = new[] { request },
                AWSAccessKeyId = ConfigurationManager.AppSettings["accessKeyId"],
                AssociateTag   = "ReplaceWithYourValue"
            };

            // send the ItemSearch request
            ItemSearchResponse response = amazonClient.ItemSearch(itemSearch);

            // write out the results from the ItemSearch request
            foreach (var item in response.Items[0].Item)
            {
                Console.WriteLine(item.ItemAttributes.Title);
            }
            Console.WriteLine("done...enter any key to continue>");
            Console.ReadLine();
        }
Example #5
0
    private string getImageURL(string asin)
    {
        const string accessKeyId = "AKIAINHOZEYXDKHXMYUQ";
        const string secretKey   = "julQsMkFls7gezSrs9pF5dQjv1zQ9OazqrPixgUj";

        // create a WCF Amazon ECS client
        AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient(
            new BasicHttpBinding(BasicHttpSecurityMode.Transport),
            new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));

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

        // prepare an ItemSearch request
        ItemLookupRequest request = new ItemLookupRequest();

        request.ItemId        = new string[] { asin };
        request.ResponseGroup = new string[] { "Images" };
        request.MerchantId    = "Amazon";

        ItemLookup itemSearch = new ItemLookup();

        itemSearch.Request        = new ItemLookupRequest[] { request };
        itemSearch.AWSAccessKeyId = accessKeyId;
        itemSearch.AssociateTag   = "rgreuel-20";

        // issue the ItemSearch request
        ItemLookupResponse response = client.ItemLookup(itemSearch);

        Item returnedItem = response.Items[0].Item.First();

        return("<img src=\"" + returnedItem.MediumImage.URL + "\"/>");
    }
Example #6
0
        public static void AmazonWCF()
        {
            // create a WCF Amazon ECS client
            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(accessKeyId, secretKey));

            // prepare an ItemSearch request
            ItemSearchRequest request = new ItemSearchRequest();

            request.SearchIndex   = "Electronics";
            request.Title         = "Monitor";
            request.ResponseGroup = new string[] { "Small" };

            ItemSearch itemSearch = new ItemSearch();

            itemSearch.Request        = new ItemSearchRequest[] { request };
            itemSearch.AWSAccessKeyId = accessKeyId;
            //itemSearch.AssociateTag = tab
            // issue the ItemSearch request
            ItemSearchResponse response = client.ItemSearch(itemSearch);

            // write out the results
            foreach (var item in response.Items[0].Item)
            {
                Console.WriteLine(item.ItemAttributes.Title);
            }
        }
Example #7
0
        public IEnumerable <Item> GetProducts(string sona, int leht)
        {
            AWSECommerceServicePortTypeClient ecs = new AWSECommerceServicePortTypeClient();
            ItemSearchRequest paring = new ItemSearchRequest();

            paring.ResponseGroup = new string[] { "ItemAttributes,OfferSummary" };
            paring.SearchIndex   = "All";
            paring.Keywords      = sona;
            paring.ItemPage      = String.Format("{0}", leht);
            paring.MinimumPrice  = "0";

            ItemSearch otsi = new ItemSearch();

            otsi.Request        = new ItemSearchRequest[] { paring };
            otsi.AWSAccessKeyId = ConfigurationManager.AppSettings["accessKeyId"];
            otsi.AssociateTag   = ConfigurationManager.AppSettings["associateTag"];
            ItemSearchResponse vastus = ecs.ItemSearch(otsi);

            if (vastus == null)
            {
                throw new Exception("Server Error - didn't get any reponse from server!");
            }
            else if (vastus.OperationRequest.Errors != null)
            {
                throw new Exception(vastus.OperationRequest.Errors[0].Message);
            }
            else if (vastus.Items[0].Item == null)
            {
                throw new Exception("Didn't get any items!Try agen with different keyword.");
            }
            else
            {
                return(vastus.Items[0].Item);
            }
        }
Example #8
0
        public string getCurrentPrice(string itemID)
        {
            const string accessKeyId = "AKIAINHOZEYXDKHXMYUQ";
            const string secretKey   = "julQsMkFls7gezSrs9pF5dQjv1zQ9OazqrPixgUj";

            // create a WCF Amazon ECS client
            AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient(
                new BasicHttpBinding(BasicHttpSecurityMode.Transport),
                new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));

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

            // prepare an ItemSearch request
            ItemLookupRequest request = new ItemLookupRequest();

            request.ItemId        = new string[] { itemID };
            request.ResponseGroup = new string[] { "OfferSummary" };
            request.MerchantId    = "Amazon";

            ItemLookup itemSearch = new ItemLookup();

            itemSearch.Request        = new ItemLookupRequest[] { request };
            itemSearch.AWSAccessKeyId = accessKeyId;
            itemSearch.AssociateTag   = "rgreuel-20";

            // issue the ItemSearch request
            ItemLookupResponse response = client.ItemLookup(itemSearch);

            // write out the results
            Item returnedItem = response.Items[0].Item.First();

            return((returnedItem.OfferSummary.LowestNewPrice.FormattedPrice).Substring(1, returnedItem.OfferSummary.LowestNewPrice.FormattedPrice.Length - 1));
        }
Example #9
0
        public ItemSearchResponse ItemSearch(string SearchIndex, string[] Group, string Keywords)
        {
            BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);

            binding.MaxReceivedMessageSize = int.MaxValue;
            binding.MaxBufferSize          = int.MaxValue;

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

            // add authentication to the ECS client
            amazonClient.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(ConfigurationManager.AppSettings["accessKeyId"], ConfigurationManager.AppSettings["secretKey"]));

            ItemSearchRequest search = new ItemSearchRequest();

            search.SearchIndex   = SearchIndex;
            search.ResponseGroup = Group;
            search.Keywords      = Keywords;

            ItemSearch itemSearch = new ItemSearch();

            itemSearch.Request        = new ItemSearchRequest[] { search };
            itemSearch.AWSAccessKeyId = ConfigurationManager.AppSettings["accessKeyId"];
            itemSearch.AssociateTag   = ConfigurationManager.AppSettings["associateTag"];

            ItemSearchResponse response = amazonClient.ItemSearch(itemSearch);

            return(response);
        }
        public IEnumerable<Item> GetProducts(string sona, int leht)
        {
            AWSECommerceServicePortTypeClient ecs = new AWSECommerceServicePortTypeClient();
            ItemSearchRequest paring = new ItemSearchRequest();
            paring.ResponseGroup = new string[] { "ItemAttributes,OfferSummary" };
            paring.SearchIndex = "All";
            paring.Keywords = sona;
            paring.ItemPage = String.Format("{0}", leht);
            paring.MinimumPrice = "0";

            ItemSearch otsi = new ItemSearch();
            otsi.Request = new ItemSearchRequest[] { paring };
            otsi.AWSAccessKeyId = ConfigurationManager.AppSettings["accessKeyId"];
            otsi.AssociateTag = ConfigurationManager.AppSettings["associateTag"];
            ItemSearchResponse vastus = ecs.ItemSearch(otsi);

            if (vastus == null)
            {
                throw new Exception("Server Error - didn't get any reponse from server!");
            }
            else if (vastus.OperationRequest.Errors != null)
            {
                throw new Exception(vastus.OperationRequest.Errors[0].Message);
            }
            else if (vastus.Items[0].Item == null)
            {                
                throw new Exception("Didn't get any items!Try agen with different keyword.");
            }
            else
            {
                return vastus.Items[0].Item;
            }
        }
Example #11
0
        public static void AmazonWCF()
        {
            // create a WCF Amazon ECS client
            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(accessKeyId, secretKey));

            // prepare an ItemSearch request
            ItemSearchRequest request = new ItemSearchRequest();
            request.SearchIndex = "Electronics";
            request.Title = "Monitor";
            request.ResponseGroup = new string[] { "Small" };

            ItemSearch itemSearch = new ItemSearch();
            itemSearch.Request = new ItemSearchRequest[] { request };
            itemSearch.AWSAccessKeyId = accessKeyId;
            //itemSearch.AssociateTag = tab
            // issue the ItemSearch request
            ItemSearchResponse response = client.ItemSearch(itemSearch);

            // write out the results
            foreach (var item in response.Items[0].Item)
            {
                Console.WriteLine(item.ItemAttributes.Title);
            }
        }
Example #12
0
        private static IEnumerable <ItemAlternateVersion> GetAlternateVersions(AWSECommerceServicePortTypeClient client, string asin)
        {
            ItemLookupRequest request = new ItemLookupRequest();

            request.IdType        = ItemLookupRequestIdType.ASIN;
            request.ItemId        = new string[] { asin };
            request.ResponseGroup = new string[] { "AlternateVersions" };

            ItemLookup lookup = new ItemLookup();

            lookup.AWSAccessKeyId = access_key_id;
            lookup.AssociateTag   = associate_tag;
            lookup.Request        = new ItemLookupRequest[] { request };

            var response = client.ItemLookup(lookup);

            if (response.Items != null && response.Items.Count() > 0)
            {
                var items = response.Items[0];
                if (items.Item != null && items.Item.Count() > 0)
                {
                    var item = items.Item[0];
                    if (item.AlternateVersions != null && item.AlternateVersions.Count() > 0)
                    {
                        return(item.AlternateVersions);
                    }
                }
            }
            return(null);
        }
Example #13
0
        static void Main(string[] args)
        {
            var ci = CultureInfo.InvariantCulture.Clone() as CultureInfo;

            ci.NumberFormat.NumberDecimalSeparator = ".";

            List <string> products = new List <string>();
            List <string> price    = new List <string>();
            // Instantiate Amazon ProductAdvertisingAPI client
            AWSECommerceServicePortTypeClient amazonClient = new AWSECommerceServicePortTypeClient();


            for (int i = 1; i <= 6; i++)
            {
                // prepare an ItemSearch request
                ItemSearchRequest request = new ItemSearchRequest();
                request.SearchIndex = "All";
                //request.Title = "WCF";
                request.Keywords      = "playstation -kindle";
                request.ResponseGroup = new string[] { "ItemAttributes", "Images" };
                request.ItemPage      = i.ToString();



                ItemSearch itemSearch = new ItemSearch();
                itemSearch.Request        = new ItemSearchRequest[] { request };
                itemSearch.AWSAccessKeyId = ConfigurationManager.AppSettings["accessKeyId"];
                itemSearch.AssociateTag   = "testfo-20";


                // send the ItemSearch request
                ItemSearchResponse response = amazonClient.ItemSearch(itemSearch);
            }
        }
        public ItemSearchResponse ItemSearch(string SearchIndex, string[] Group, string Keywords)
        {
            BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
            binding.MaxReceivedMessageSize = int.MaxValue;
            binding.MaxBufferSize = int.MaxValue;

            AWSECommerceServicePortTypeClient amazonClient = new AWSECommerceServicePortTypeClient(
                        binding,
                        new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));
            // add authentication to the ECS client
            amazonClient.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(ConfigurationManager.AppSettings["accessKeyId"], ConfigurationManager.AppSettings["secretKey"]));

            ItemSearchRequest search = new ItemSearchRequest();
            search.SearchIndex = SearchIndex;
            search.ResponseGroup = Group;
            search.Keywords = Keywords;

            ItemSearch itemSearch = new ItemSearch();
            itemSearch.Request = new ItemSearchRequest[] { search };
            itemSearch.AWSAccessKeyId = ConfigurationManager.AppSettings["accessKeyId"];
            itemSearch.AssociateTag = ConfigurationManager.AppSettings["associateTag"];

            ItemSearchResponse response = amazonClient.ItemSearch(itemSearch);
            return response;
        }
Example #15
0
        public string ReviewsFrame()
        {
            BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
            binding.MaxReceivedMessageSize = int.MaxValue;
            binding.MaxBufferSize = int.MaxValue;

            AWSECommerceServicePortTypeClient amazonClient = new AWSECommerceServicePortTypeClient(
                        binding,
                        new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));
            // add authentication to the ECS client
            amazonClient.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(ConfigurationManager.AppSettings["accessKeyId"], ConfigurationManager.AppSettings["secretKey"]));

            ItemLookupRequest request = new ItemLookupRequest();
            request.ItemId = this.ItemIds;
            request.IdType = ItemLookupRequestIdType.ASIN;
            request.ResponseGroup = new string[] { "Reviews" };

            ItemLookup itemLookup = new ItemLookup();
            itemLookup.Request = new ItemLookupRequest[] { request };
            itemLookup.AWSAccessKeyId = ConfigurationManager.AppSettings["accessKeyId"];
            itemLookup.AssociateTag = ConfigurationManager.AppSettings["associateTag"];

            ItemLookupResponse response = amazonClient.ItemLookup(itemLookup);
            string frameUrl = response.Items[0].Item[0].CustomerReviews.IFrameURL;
            return frameUrl;
        }
Example #16
0
        private AWSECommerceServicePortType CreateClient()
        {
            var client = new AWSECommerceServicePortTypeClient();

            client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(accessKeyId, secretKey));
            return(client);
        }
Example #17
0
        static void Main(string[] args)
        {
            // Instantiate Amazon ProductAdvertisingAPI client
            AWSECommerceServicePortTypeClient amazonClient = new AWSECommerceServicePortTypeClient();

            // prepare an ItemSearch request
            ItemSearchRequest request = new ItemSearchRequest
            {
                SearchIndex = "Books",
                Title = "WCF",
                ResponseGroup = new[] {"Small"}
            };

            ItemSearch itemSearch = new ItemSearch
            {
                Request = new[] {request},
                AWSAccessKeyId = ConfigurationManager.AppSettings["accessKeyId"],
                AssociateTag = "ReplaceWithYourValue"
            };

            // send the ItemSearch request
            ItemSearchResponse response = amazonClient.ItemSearch(itemSearch);

            // write out the results from the ItemSearch request
            foreach (var item in response.Items[0].Item)
            {
                Console.WriteLine(item.ItemAttributes.Title);
            }
            Console.WriteLine("done...enter any key to continue>");
            Console.ReadLine();
        }
Example #18
0
        static void Main(string[] args)
        {
            var ci = CultureInfo.InvariantCulture.Clone() as CultureInfo;
            ci.NumberFormat.NumberDecimalSeparator = ".";

            List<string> products = new List<string>();
            List<string> price = new List<string>();
            // Instantiate Amazon ProductAdvertisingAPI client
            AWSECommerceServicePortTypeClient amazonClient = new AWSECommerceServicePortTypeClient();

            for (int i = 1; i <= 6; i++)
            {
                // prepare an ItemSearch request
                ItemSearchRequest request = new ItemSearchRequest();
                request.SearchIndex = "All";
                //request.Title = "WCF";
                request.Keywords = "playstation -kindle";
                request.ResponseGroup = new string[] {"ItemAttributes", "Images"};
                request.ItemPage = i.ToString();

                ItemSearch itemSearch = new ItemSearch();
                itemSearch.Request = new ItemSearchRequest[] { request };
                itemSearch.AWSAccessKeyId = ConfigurationManager.AppSettings["accessKeyId"];
                itemSearch.AssociateTag = "testfo-20";

                // send the ItemSearch request
                ItemSearchResponse response = amazonClient.ItemSearch(itemSearch);

            }
        }
Example #19
0
        private static IEnumerable<ItemAlternateVersion> GetAlternateVersions(AWSECommerceServicePortTypeClient client, string asin)
        {
            ItemLookupRequest request = new ItemLookupRequest();
            request.IdType = ItemLookupRequestIdType.ASIN;
            request.ItemId = new string[] { asin };
            request.ResponseGroup = new string[] { "AlternateVersions" };

            ItemLookup lookup = new ItemLookup();
            lookup.AWSAccessKeyId = access_key_id;
            lookup.AssociateTag = associate_tag;
            lookup.Request = new ItemLookupRequest[] { request };

            var response = client.ItemLookup(lookup);

            if (response.Items != null && response.Items.Count() > 0)
            {
                var items = response.Items[0];
                if (items.Item != null && items.Item.Count() > 0)
                {
                    var item = items.Item[0];
                    if (item.AlternateVersions != null && item.AlternateVersions.Count() > 0)
                        return item.AlternateVersions;
                }
            }
            return null;
        }
    public string getCurrentPrice(string itemID)
    {
        const string accessKeyId = "AKIAINHOZEYXDKHXMYUQ";
        const string secretKey = "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";

        // create a WCF Amazon ECS client
        AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient(
            new BasicHttpBinding(BasicHttpSecurityMode.Transport),
            new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));

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

        // prepare an ItemSearch request
        ItemLookupRequest request = new ItemLookupRequest();
        request.ItemId = new string[] { itemID };
        request.ResponseGroup = new string[] { "OfferSummary" };
        request.MerchantId = "Amazon";

        ItemLookup itemSearch = new ItemLookup();
        itemSearch.Request = new ItemLookupRequest[] { request };
        itemSearch.AWSAccessKeyId = accessKeyId;
        itemSearch.AssociateTag = "rgreuel-20";

        // issue the ItemSearch request
        ItemLookupResponse response = client.ItemLookup(itemSearch);

        // write out the results
        Item returnedItem = response.Items[0].Item.First();

        return (returnedItem.OfferSummary.LowestNewPrice.FormattedPrice).Substring(1, returnedItem.OfferSummary.LowestNewPrice.FormattedPrice.Length - 1);
    }
        private static ItemSearchResponse DoAmazonItemSearch(string keywords, int page)        //AWSECommerceServicePortTypeClient ecs, ItemSearchRequest request)
        {
            ItemSearchResponse response = null;

            // Create an ItemSearch wrapper
            ItemSearch search = new ItemSearch();

            search.AssociateTag   = _ASSOCIATE_TAG;
            search.AWSAccessKeyId = _ACCESS_KEY_ID;

            AWSECommerceServicePortTypeClient ecs = GetClient();
            ItemSearchRequest request             = GetSearchRequest();

            request.Keywords = keywords;
            request.ItemPage = Convert.ToString(page);

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

            try
            {
                //Send the request and store the response
                response = ecs.ItemSearch(search);
            }
            catch (NullReferenceException e)
            {
                Debug.WriteLine(e.ToString());
            }
            return(response);
        }
        private static Item[] DoAmazonItemLookup(string[] ASINs)
        {
            ItemLookupResponse response = null;

            AWSECommerceServicePortTypeClient ecs = GetClient();
            ItemLookupRequest request             = GetLookupRequest();

            request.ItemId = ASINs;

            ItemLookup lookup = new ItemLookup();

            lookup.AssociateTag   = _ASSOCIATE_TAG;
            lookup.AWSAccessKeyId = _ACCESS_KEY_ID;

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

            try
            {
                //Send the request and store the response
                response = ecs.ItemLookup(lookup);
            }
            catch (NullReferenceException e)
            {
                Debug.WriteLine(e.ToString());
            }

            if (response == null)
            {
                throw new Exception("Request did not return a response. Error using Amazon API");
            }

            return(response.Items[0].Item);
        }
Example #23
0
        public AmazonRepository()
        {
            client = new AWSECommerceServicePortTypeClient();
            var keyid = Encoding.ASCII.GetString(Convert.FromBase64String(ConfigurationManager.AppSettings["keyid"]));
            var key   = Encoding.ASCII.GetString(Convert.FromBase64String(ConfigurationManager.AppSettings["key"]));

            client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(keyid, key));
        }
        static AWSECommerceServiceInstance()
        {
            var binding = new BasicHttpBinding();
            binding.Security.Mode = BasicHttpSecurityMode.Transport;

            awseCommerceService = new AWSECommerceServicePortTypeClient(
                binding,
                new EndpointAddress("https://ecs.amazonaws.com/onca/soap?Service=AWSECommerceService"));
        }
Example #25
0
        public AmazonService()
        {
            binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
            binding.MaxReceivedMessageSize = int.MaxValue;

            client = new AWSECommerceServicePortTypeClient(binding,
                                new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));
            
            client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(Settings.AMAZON_ACCESS_KEY_ID, Settings.AMAZON_SECRET_KEY));
        }
Example #26
0
        public AmazonService()
        {
            binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
            binding.MaxReceivedMessageSize = int.MaxValue;

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

            client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(Settings.AMAZON_ACCESS_KEY_ID, Settings.AMAZON_SECRET_KEY));
        }
Example #27
0
    // perform the Amazon search with SOAP and return results as a DataTable
    public static DataTable GetAmazonDataWithSoap()
    {
        // Create Amazon objects
        AWSECommerceServicePortTypeClient amazonService = new AWSECommerceServicePortTypeClient();
        ItemSearch         itemSearch        = new ItemSearch();
        ItemSearchRequest  itemSearchRequest = new ItemSearchRequest();
        ItemSearchResponse itemSearchResponse;

        // Setup Amazon objects
        itemSearch.AWSAccessKeyId       = BalloonShopConfiguration.SubscriptionId;
        itemSearchRequest.Keywords      = BalloonShopConfiguration.SearchKeywords;
        itemSearchRequest.SearchIndex   = BalloonShopConfiguration.SearchIndex;
        itemSearchRequest.ResponseGroup =
            BalloonShopConfiguration.ResponseGroups.Split(',');
        itemSearch.Request = new ItemSearchRequest[1] {
            itemSearchRequest
        };

        // Will store search results
        DataTable responseTable = GetResponseTable();

        // If any problems occur, we prefer to send back empty result set
        // instead of throwing exception
        try
        {
            itemSearchResponse = amazonService.ItemSearch(itemSearch);
            Item[] results = itemSearchResponse.Items[0].Item;
            // Browse the results
            foreach (Item item in results)
            {
                // product with incomplete information will be ignored
                try
                {
                    //create a datarow, populate it and add it to the table
                    DataRow dataRow = responseTable.NewRow();
                    dataRow["ASIN"]            = item.ASIN;
                    dataRow["ProductName"]     = item.ItemAttributes.Title;
                    dataRow["ProductImageUrl"] = item.SmallImage.URL;
                    dataRow["ProductPrice"]    = item.OfferSummary.LowestNewPrice.
                                                 FormattedPrice;
                    responseTable.Rows.Add(dataRow);
                }
                catch
                {
                    // Ignore products with incomplete information
                }
            }
        }
        catch (Exception e)
        {
            // ignore the error
        }
        // return the results
        return(responseTable);
    }
Example #28
0
        private static AWSECommerceServicePortTypeClient ConstructAWSProvider()
        {
            BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);

            binding.MaxReceivedMessageSize = Int32.MaxValue;
            EndpointAddress endpoint = new EndpointAddress("https://ecs.amazonaws.com/onca/soap?Service=AWSECommerceService");
            //// https://webservices.amazon.com/onca/soap?Service=AWSECommerceService
            AWSECommerceServicePortTypeClient aws = new AWSECommerceServicePortTypeClient(binding, endpoint);

            aws.ChannelFactory.Endpoint.EndpointBehaviors.Add(new AmazonSigningEndpointBehavior(awsAccessKeyId, secretAccessKey));
            return(aws);
        }
Example #29
0
    // perform the Amazon search with SOAP and return results as a DataTable
    public static DataTable GetAmazonDataWithSoap()
    {
        // Create Amazon objects
        AWSECommerceServicePortTypeClient amazonService = new AWSECommerceServicePortTypeClient();
        ItemSearch itemSearch = new ItemSearch();
        ItemSearchRequest itemSearchRequest = new ItemSearchRequest();
        ItemSearchResponse itemSearchResponse;
        // Setup Amazon objects
        itemSearch.AWSAccessKeyId = BalloonShopConfiguration.SubscriptionId;
        itemSearchRequest.Keywords = BalloonShopConfiguration.SearchKeywords;
        itemSearchRequest.SearchIndex = BalloonShopConfiguration.SearchIndex;
        itemSearchRequest.ResponseGroup =
        BalloonShopConfiguration.ResponseGroups.Split(',');
        itemSearch.Request = new ItemSearchRequest[1] { itemSearchRequest };

        // Will store search results
        DataTable responseTable = GetResponseTable();
        // If any problems occur, we prefer to send back empty result set
        // instead of throwing exception
        try
        {
          itemSearchResponse = amazonService.ItemSearch(itemSearch);
          Item[] results = itemSearchResponse.Items[0].Item;
          // Browse the results
          foreach (Item item in results)
          {
        // product with incomplete information will be ignored
        try
        {

          //create a datarow, populate it and add it to the table
          DataRow dataRow = responseTable.NewRow();
          dataRow["ASIN"] = item.ASIN;
          dataRow["ProductName"] = item.ItemAttributes.Title;
          dataRow["ProductImageUrl"] = item.SmallImage.URL;
          dataRow["ProductPrice"] = item.OfferSummary.LowestNewPrice.
        FormattedPrice;
          responseTable.Rows.Add(dataRow);
        }
        catch
        {
          // Ignore products with incomplete information
        }
          }
        }
        catch (Exception e)
        {
          // ignore the error
        }
        // return the results
        return responseTable;
    }
Example #30
0
        private static void ItemSearch()
        {
            // Create the request object
            ItemSearchRequest request = new ItemSearchRequest();

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

            // Set SearchIndex to All and use the scanned EAN
            // as the keyword, this should generate a single response
            request.SearchIndex = "Books";
            request.Keywords    = "Century rain"; // asin = 0441013074
            request.Author      = "Alastair Reynolds";

            // Make the item search
            ItemSearch search = new ItemSearch();

            // It is ABSOLUTELY CRITICAL that you change
            // the AWSAccessKeyID to YOUR uniqe value
            // Signup for an account (and AccessKeyID) at http://aws.amazon.com/
            search.AWSAccessKeyId = access_key_id;
            search.AssociateTag   = associate_tag;

            // Set the request on the search wrapper - multiple requests
            // can be submitted on one search
            search.Request = new ItemSearchRequest[] { request };

            // Make the port
            AWSECommerceServicePortTypeClient port = new AWSECommerceServicePortTypeClient("AWSECommerceServicePort");

            port.ChannelFactory.Endpoint.EndpointBehaviors.Add(new AmazonSigningEndpointBehavior(access_key_id, secret_access_key));

            //Send the request, store the response and display some of the results
            ItemSearchResponse response = port.ItemSearch(search);

            foreach (var items in response.Items)
            {
                foreach (var item in items.Item)
                {
                    Console.WriteLine("{0}\t{1}\t{2}", item.ItemAttributes.Title, item.ASIN, item.ItemAttributes.Author[0]);

                    if (item.AlternateVersions != null)
                    {
                        Console.WriteLine(" - Alternate versions");
                        foreach (var version in item.AlternateVersions)
                        {
                            Console.WriteLine(" -- \t{0}\t{1}\t{2}", version.Title, version.Binding, version.ASIN);
                        }
                    }
                }
            }
        }
Example #31
0
        public AWSHelper(string accessKeyId, string secretKey, string AssociateTag, string AWSAccessKeyId)
        {
            this.AssociateTag   = AssociateTag;
            this.AWSAccessKeyId = AWSAccessKeyId;

            BasicHttpBinding basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);

            basicHttpBinding.MaxBufferSize          = int.MaxValue;
            basicHttpBinding.MaxReceivedMessageSize = 2147483647;
            client = new AWSECommerceServicePortTypeClient(basicHttpBinding,
                                                           new EndpointAddress("https://webservices.amazon.com.mx/onca/soap?Service=AWSECommerceService"));
            client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(accessKeyId, secretKey));
        }
Example #32
0
        private static void GetVariations(AWSECommerceServicePortTypeClient client, string asin)
        {
            ItemLookupRequest request = new ItemLookupRequest();
            request.IdType = ItemLookupRequestIdType.ASIN;
            request.ItemId = new string[] { asin };
            request.ResponseGroup = new string[] { "Variations" };

            ItemLookup lookup = new ItemLookup();
            lookup.AWSAccessKeyId = access_key_id;
            lookup.AssociateTag = associate_tag;
            lookup.Request = new ItemLookupRequest[] { request };

            var response = client.ItemLookup(lookup);
        }
Example #33
0
        public DataTable GetProducts(string productName)
        {
            DataTable products = new DataTable();

            products.Columns.Add("Product", typeof(string));
            products.Columns.Add("Price", typeof(string));
            products.Columns.Add("Image", typeof(string));
            products.Columns.Add("url", typeof(string));



            // Instantiate Amazon ProductAdvertisingAPI client
            AWSECommerceServicePortTypeClient amazonClient = new AWSECommerceServicePortTypeClient();

            for (int i = 1; i <= 5; i++)
            {
                // prepare an ItemSearch request
                ItemSearchRequest request = new ItemSearchRequest();
                request.SearchIndex   = "All";
                request.Keywords      = productName + " -kindle";
                request.ResponseGroup = new string[] { "ItemAttributes", "Images" };
                request.ItemPage      = i.ToString();
                request.Condition     = Condition.New;
                request.Availability  = ItemSearchRequestAvailability.Available;

                ItemSearch itemSearch = new ItemSearch();
                itemSearch.Request        = new ItemSearchRequest[] { request };
                itemSearch.AWSAccessKeyId = ConfigurationManager.AppSettings["accessKeyId"];
                itemSearch.AssociateTag   = "testfo-20";

                // send the ItemSearch request
                ItemSearchResponse response = amazonClient.ItemSearch(itemSearch);



                foreach (var item in response.Items[0].Item)
                {
                    try
                    {
                        products.Rows.Add(item.ItemAttributes.Title, item.ItemAttributes.ListPrice.FormattedPrice.Replace("$", ""), item.SmallImage.URL, item.DetailPageURL);
                    }

                    catch (NullReferenceException ex) {
                        Debug.WriteLine("Caught Exception: " + ex.Message);
                        continue;
                    }
                }
            }
            return(products);
        }
Example #34
0
        public DataTable GetProducts(string productName)
        {
            DataTable products = new DataTable();
                products.Columns.Add("Product", typeof(string));
                products.Columns.Add("Price", typeof(string));
                products.Columns.Add("Image", typeof(string));
                products.Columns.Add("url", typeof(string));

                // Instantiate Amazon ProductAdvertisingAPI client
                AWSECommerceServicePortTypeClient amazonClient = new AWSECommerceServicePortTypeClient();
                for (int i = 1; i <= 5; i++)
                {

                    // prepare an ItemSearch request
                    ItemSearchRequest request = new ItemSearchRequest();
                    request.SearchIndex = "All";
                    request.Keywords = productName + " -kindle";
                    request.ResponseGroup = new string[] { "ItemAttributes", "Images"};
                    request.ItemPage = i.ToString();
                    request.Condition = Condition.New;
                    request.Availability = ItemSearchRequestAvailability.Available;

                    ItemSearch itemSearch = new ItemSearch();
                    itemSearch.Request = new ItemSearchRequest[] { request };
                    itemSearch.AWSAccessKeyId = ConfigurationManager.AppSettings["accessKeyId"];
                    itemSearch.AssociateTag = "testfo-20";

                    // send the ItemSearch request
                    ItemSearchResponse response = amazonClient.ItemSearch(itemSearch);

                    foreach (var item in response.Items[0].Item)
                    {
                        try
                        {

                                products.Rows.Add(item.ItemAttributes.Title, item.ItemAttributes.ListPrice.FormattedPrice.Replace("$", ""),item.SmallImage.URL, item.DetailPageURL);

                        }

                         catch (NullReferenceException ex) {
                           Debug.WriteLine("Caught Exception: " + ex.Message);
                           continue;
                        }

                    }

                }
                return products;
        }
Example #35
0
        protected ServiceBase(string accessKey, string secretKey, string associateTag)
        {
            AccessKey = accessKey;
            AssociateTag = associateTag;

            var binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport) { MaxReceivedMessageSize = int.MaxValue };
            client = new AWSECommerceServicePortTypeClient(
                binding,
                new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));

            client.ChannelFactory.Endpoint.Behaviors.Add(
                new AmazonSigningEndpointBehavior(accessKey, secretKey));
            Merchant = Merchants.All;
            SetupUSBrowserNodes();
        }
        private static AWSECommerceServicePortTypeClient getAWSECommerceServiceClient()
        {
            // create a WCF Amazon ECS client
            BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
            binding.MaxReceivedMessageSize = int.MaxValue;
            AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient(
                binding,
                new EndpointAddress(EndPointUri)
            );

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

            return client;
        }
Example #37
0
        private static ItemLookupResponse ItemLookup(AWSECommerceServicePortTypeClient client, string asin)
        {
            ItemLookupRequest request = new ItemLookupRequest();
            request.IdType = ItemLookupRequestIdType.ASIN;
            request.ItemId = new string[] { asin };
            request.ResponseGroup = new string[] { "Large", "ItemAttributes", "AlternateVersions", "Variations" };

            ItemLookup lookup = new ItemLookup();
            lookup.AWSAccessKeyId = access_key_id;
            lookup.AssociateTag = associate_tag;
            lookup.Request = new ItemLookupRequest[] { request };

            var response = client.ItemLookup(lookup);
            return response;
        }
        public AmazonProductAdvertisingRequestor(string accessKey, string secretKey, string assocaiteKey)
        {
            _accessKey    = accessKey;
            _secretKey    = secretKey;
            _associateKey = assocaiteKey;

            // create a WCF Amazon ECS client
            var binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);

            binding.MaxReceivedMessageSize = int.MaxValue;
            _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(_accessKey, _secretKey));
        }
        private static AWSECommerceServicePortTypeClient GetClient()
        {
            // Create an instance of the Product Advertising API service
            BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);

            binding.MaxReceivedMessageSize = int.MaxValue;

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

            // add authentication to the ECS client
            ecs.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(_ACCESS_KEY_ID, _SECRET_KEY));

            return(ecs);
        }
Example #40
0
        private static void GetVariations(AWSECommerceServicePortTypeClient client, string asin)
        {
            ItemLookupRequest request = new ItemLookupRequest();

            request.IdType        = ItemLookupRequestIdType.ASIN;
            request.ItemId        = new string[] { asin };
            request.ResponseGroup = new string[] { "Variations" };

            ItemLookup lookup = new ItemLookup();

            lookup.AWSAccessKeyId = access_key_id;
            lookup.AssociateTag   = associate_tag;
            lookup.Request        = new ItemLookupRequest[] { request };

            var response = client.ItemLookup(lookup);
        }
Example #41
0
        public static List<System.Drawing.Image> SearchAlbumArt(string keywords)
        {
            try
            {
                keywords = CleanString(keywords);

                ItemSearchRequest itemRequest = new ItemSearchRequest();
                itemRequest.Keywords = keywords;
                // http://docs.amazonwebservices.com/AWSECommerceService/2009-02-01/DG/index.html?ItemLookup.html
                itemRequest.SearchIndex = "Music"; // Other possibly valid choices:Classical, DigitalMusic, Mp3Downloads, Music, MusicTracks,
                itemRequest.ResponseGroup = new string[] { "Images" }; // images only

                ItemSearch request = new ItemSearch();
                request.AWSAccessKeyId = Credentials.AmazonAccessKeyId;
                request.Request = new ItemSearchRequest[] { itemRequest };

                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"));
                client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(Credentials.AmazonAccessKeyId, Credentials.AmazonSecretKey));
                ItemSearchResponse response = client.ItemSearch(request);

                // Determine if book was found
                bool itemFound = ((response.Items[0].Item != null) && (response.Items[0].Item.Length > 0));

                if (itemFound)
                {
                    List<System.Drawing.Image> images = new List<System.Drawing.Image>();

                    foreach (Item currItem in response.Items[0].Item)
                    {
                        try
                        {
                            if (currItem != null && currItem.LargeImage != null)
                                images.Add(ConvertByteArrayToImage(GetBytesFromUrl(currItem.LargeImage.URL)));
                        }
                        catch { }
                    }

                    return images;
                }
            }
            catch (Exception) {}

            return null;
        }
Example #42
0
        private static SimilarityLookupResponse SimilarityLookup(AWSECommerceServicePortTypeClient client, string asin)
        {
            var request = new SimilarityLookupRequest();

            request.ItemId        = new string[] { asin };
            request.ResponseGroup = new string[] { "Large", "ItemAttributes" };

            var lookup = new SimilarityLookup();

            lookup.AWSAccessKeyId = access_key_id;
            lookup.AssociateTag   = associate_tag;
            lookup.Request        = new SimilarityLookupRequest[] { request };

            var response = client.SimilarityLookup(lookup);

            return(response);
        }
Example #43
0
        private static ItemLookupResponse ItemLookup(AWSECommerceServicePortTypeClient client, string asin)
        {
            ItemLookupRequest request = new ItemLookupRequest();

            request.IdType        = ItemLookupRequestIdType.ASIN;
            request.ItemId        = new string[] { asin };
            request.ResponseGroup = new string[] { "Large", "ItemAttributes", "AlternateVersions", "Variations" };

            ItemLookup lookup = new ItemLookup();

            lookup.AWSAccessKeyId = access_key_id;
            lookup.AssociateTag   = associate_tag;
            lookup.Request        = new ItemLookupRequest[] { request };

            var response = client.ItemLookup(lookup);

            return(response);
        }
Example #44
0
        static void Main(string[] args)
        {
            // Make the client
            AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient("AWSECommerceServicePort");

            client.ChannelFactory.Endpoint.EndpointBehaviors.Add(new AmazonSigningEndpointBehavior(access_key_id, secret_access_key));

            //var versions = GetAlternateVersions(client, "0441013074");
            //SaveObject(versions, "alternate_versions.txt");

            //GetVariations(client, "0441013074");

            var similar = SimilarityLookup(client, "0441013074");

            SaveObject(similar, "similar_0441013074.txt");

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
Example #45
0
        //returns response from Amazon search request
        public static ItemSearchResponse search(ItemSearchRequest request)
        {
            // create a WCF Amazon ECS client
            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(Globals.ACCESS_KEY_ID, Globals.SECRET_KEY));

            ItemSearch itemSearch = new ItemSearch();
            itemSearch.Request = new ItemSearchRequest[] { request };
            itemSearch.AWSAccessKeyId = Globals.ACCESS_KEY_ID;
            itemSearch.AssociateTag = "";

            // issue the ItemSearch request
            return client.ItemSearch(itemSearch);
        }
Example #46
0
        protected ServiceBase(string accessKey, string secretKey, string associateTag)
        {
            AccessKey    = accessKey;
            AssociateTag = associateTag;

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

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

            client.ChannelFactory.Endpoint.Behaviors.Add(
                new AmazonSigningEndpointBehavior(accessKey, secretKey));
            Merchant = Merchants.All;
            SetupUSBrowserNodes();
        }
Example #47
0
		/// <summary>
		/// Creates a <see cref="AWSECommerceServicePortTypeClient"/> for use in the DAO.
		/// </summary>
		/// <returns></returns>
		public static AWSECommerceServicePortTypeClient CreateAmazonServiceClient(
			string address, string accessKey, string secretKey, string nameSpace)
		{
			BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport)
						{
						MaxReceivedMessageSize = int.MaxValue
						};

			AmazonSigningEndpointBehavior signingBehavior = new AmazonSigningEndpointBehavior(accessKey, secretKey, nameSpace);

			AWSECommerceServicePortTypeClient amazonClient = new AWSECommerceServicePortTypeClient
						(
						binding,
						new EndpointAddress(address)
						);

			amazonClient.ChannelFactory.Endpoint.Behaviors.Add(signingBehavior);

			return amazonClient;
		}
Example #48
0
        public AWSHelper(string ENDPOINT, string MY_AWS_ACCESS_KEY_ID, string MY_AWS_SECRET_KEY, string NAMESPACE)
        {
            // Constructor to populate responseItems
            // Accepts various standard AWS parameters and search string

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

            // Client
            client = new AWSECommerceServicePortTypeClient(
                binding, new EndpointAddress(ENDPOINT));
            client.ChannelFactory.Endpoint.Behaviors.Add(
                new AmazonSigningEndpointBehavior(MY_AWS_ACCESS_KEY_ID, MY_AWS_SECRET_KEY, NAMESPACE));

            // ItemSearchREquest
            request = new ItemSearchRequest();
            request.ResponseGroup = new string[] { "Medium" };

            itemSearch = new ItemSearch();
            itemSearch.AWSAccessKeyId = MY_AWS_ACCESS_KEY_ID;
        }
Example #49
0
        public MainForm()
        {
            InitializeComponent();

            btnUpdateBookDetailFromApi.VerticalText       = "1. API - Get details for selected books";
            btnUpdateBookDetailFromHtml.VerticalText      = "2. HTML - Get details for selected books";
            btnUpdateBookStatsFromReviewPage.VerticalText = "[redun]3a. REVIEW - Get rating stats for selected books";
            btnUpdateBookRankFromHTML.VerticalText        = "3b. HTML - Get rankings for selected books";
            btnUpdateBookReviewFromHTML.VerticalText      = "4. REVIEW - Get reviews for selected books";
            btnUpdateAuthorRank.VerticalText = "5. AUTHOR - Get rankings for authors";

            lstBooks.DisplayMember = "DisplayString";
            txtOutputLog.Text      = "---OUTPUT LOG---" + Environment.NewLine;

            nudToLoad.Value = 10;
            toolTipAllAuthors.SetToolTip(this.chkAllAuthors, "Default is to only load authors still without rankings (i.e. unprocessed)");

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

            XmlDictionaryReaderQuotas readerQuotas = new XmlDictionaryReaderQuotas();

            readerQuotas.MaxArrayLength         = int.MaxValue;
            readerQuotas.MaxStringContentLength = int.MaxValue;
            readerQuotas.MaxBytesPerRead        = int.MaxValue;
            readerQuotas.MaxNameTableCharCount  = int.MaxValue;

            binding.ReaderQuotas = readerQuotas;

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

            //Adding this uses the code in Amazon.PAAPI.WCF to sign requests automagically
            amazonClient.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior());
        }
Example #50
0
        public static Activity AmazonSearch(Activity activity, string searchTerm)
        {
            var accessKeyId = "AKIAIOXGBEXN4SPR5PYQ";
            var secretKey   = "EX7ljxnf4p694WyD6afvxNq67YL2n+BdOCYNc8lx";

            //var client = new AWSECommerceServicePortTypeClient();
            //client.ChannelFactory.Endpoint.Behaviors.Add(new Amazon.AmazonSigningEndpointBehavior(accessKeyId, secretKey));

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

            var 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(accessKeyId, secretKey));

            var lookup  = new ItemSearch();
            var request = new ItemSearchRequest();

            lookup.AssociateTag   = accessKeyId;
            lookup.AWSAccessKeyId = secretKey;
            request.Keywords      = searchTerm;
            var response = client.ItemSearch(lookup);


            var sb = new StringBuilder();

            sb.AppendLine($"Hello {activity.From.Name} - Amazon Search results for {searchTerm}." + Environment.NewLine);

            var reply = activity.CreateReply(sb.ToString());

            reply.Type = "message";
            return(reply);
        }
Example #51
0
        static void Main(string[] args)
        {
            // Instantiate Amazon ProductAdvertisingAPI client
            BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);

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

            //Adding this uses the code in Amazon.PAAPI.WCF to sign requests automagically
            amazonClient.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior());

            // prepare an ItemSearch request
            ItemSearchRequest request = new ItemSearchRequest();

            request.SearchIndex   = "DVD";
            request.Title         = "Matrix";
            request.ResponseGroup = new string[] { "Small" };

            ItemSearch itemSearch = new ItemSearch();

            itemSearch.Request      = new ItemSearchRequest[] { request };
            itemSearch.AssociateTag = "notag"; //this is a required param, so I just use a dummy value which seems to work

            // send the ItemSearch request
            ItemSearchResponse response = amazonClient.ItemSearch(itemSearch);

            // write out the results from the ItemSearch request
            foreach (var item in response.Items[0].Item)
            {
                Console.WriteLine(item.ItemAttributes.Title);
            }
            Console.WriteLine("\n\n<<< done...enter any key to continue >>>");
            Console.ReadLine();
        }
        public async Task<SongData> getData(SongData newSong, string fullRequest)
        {
            try
            {
                // Instantiate Amazon ProductAdvertisingAPI client
                BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
                binding.MaxReceivedMessageSize = int.MaxValue;
                AWSECommerceServicePortTypeClient amazonClient = new AWSECommerceServicePortTypeClient(
                binding,
                new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));

                // add authentication to the ECS client
                amazonClient.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(accessKeyId, secretKey));

                // prepare an ItemSearch request
                ItemSearchRequest request = new ItemSearchRequest();
                request.SearchIndex = "MP3Downloads";
                request.RelationshipType = new string[] { "Tracks" };
                request.ResponseGroup = new string[] { "ItemAttributes", "Images", "Offers", "RelatedItems" };

                request.Keywords = fullRequest;

                ItemSearch itemSearch = new ItemSearch();
                itemSearch.Request = new ItemSearchRequest[] { request };
                itemSearch.AWSAccessKeyId = accessKeyId;
                itemSearch.AssociateTag = "1330-3170-0573";

                // send the ItemSearch request
                ItemSearchResponse response = amazonClient.ItemSearch(itemSearch);

                var item = response.Items[0].Item[0];

                //<ProductTypeName>DOWNLOADABLE_MUSIC_TRACK</ProductTypeName>
                if (response.Items[0].Item[0].ItemAttributes.ProductTypeName == "DOWNLOADABLE_MUSIC_ALBUM")
                {
                    item = response.Items[0].Item[1];
                }

                // if no response to search
                if (item == null)
                {
                    try
                    {
                        // Try new search and remove the album
                        newSong.Album = "UNKNOWN";

                        // Re-iterate over the search method
                        await getData(newSong, fullRequest);
                    }
                    catch
                    {
                        // Removing the album produced no results
                        // Continue forward...
                    }
                }

                // Get year from full Release Date var
                var formatYear = DateTime.Parse(item.ItemAttributes.ReleaseDate).Year;

                newSong.UserID = 1;
                newSong.LocationID = 1;
                newSong.Album = item.RelatedItems[0].RelatedItem[0].Item.ItemAttributes.Title;
                newSong.Artist = item.ItemAttributes.Creator[0].Value;
                newSong.Title = item.ItemAttributes.Title;
                newSong.Year = (int)formatYear;
                newSong.Genre = item.ItemAttributes.Genre;
                newSong.FilePath = "";
                newSong.Duration = (int)item.ItemAttributes.RunningTime.Value;
                newSong.Price = item.Offers.Offer[0].OfferListing[0].Price.FormattedPrice;
                newSong.ASIN = item.ASIN;
                newSong.Artwork = item.LargeImage.URL;

                return newSong;
            }
            catch
            {
                return newSong;
            }
        }
        // the program starts here
        static void Main(string[] args)
        {
            // create a WCF Amazon ECS client
            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(accessKeyId, secretKey));

            ItemLookupRequest request2 = new ItemLookupRequest();
            request2.ItemId = new String[] { "2817801997" };
            request2.IdType = ItemLookupRequestIdType.ISBN;
            request2.ResponseGroup = new String[] { "Medium" };
            request2.IdTypeSpecified = true;
            request2.SearchIndex = "Books";

            ItemLookup itemLookup = new ItemLookup();
            itemLookup.Request = new ItemLookupRequest[] { request2 };
            itemLookup.AWSAccessKeyId = accessKeyId;
            itemLookup.AssociateTag = "213";

            ItemLookupResponse response2 = client.ItemLookup(itemLookup);

            foreach (var item in response2.Items[0].Item) {
                // Create a web request to the URL for the picture
                System.Net.WebRequest webRequest = HttpWebRequest.Create(item.MediumImage.URL);
                // Execute the request synchronuously
                HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();

                // Create an image from the stream returned by the web request
                //pCover.Image = new System.Drawing.Bitmap(webResponse.GetResponseStream());

                // Finally, close the request
                webResponse.Close();
                Console.WriteLine(item.ItemAttributes.Title);
            }

            // prepare an ItemSearch request
            ItemSearchRequest request	= new ItemSearchRequest();
            request.SearchIndex			= "Books";
            request.Title				= "Node.js";
            request.ResponseGroup 		= new string[] { "Small" };

            ItemSearch itemSearch		= new ItemSearch();
            itemSearch.Request			= new ItemSearchRequest[] { request };
            //itemSearch.AssociateTag 	= "testsite09f-21";
            itemSearch.AssociateTag 	= "213";
            itemSearch.AWSAccessKeyId	= accessKeyId;

            // issue the ItemSearch request
            ItemSearchResponse response	= client.ItemSearch(itemSearch);

            // write out the results
            foreach (var item in response.Items[0].Item) {
                Console.WriteLine(item.ItemAttributes.Title);
            }
            Console.ReadLine();
        }
Example #54
0
        public ItemSearchResponse SearchItem(ItemSearchRequest itemSearchRequest, string[] responseGroup)
        {
            itemSearchRequest.ResponseGroup = responseGroup;

            ItemSearch itemSearch = new ItemSearch();
            itemSearch.Request = new ItemSearchRequest[] { itemSearchRequest };
            itemSearch.AWSAccessKeyId = AccessKeyId;
            itemSearch.AssociateTag = AssociateTag;

            using (AWSECommerceServicePortTypeClient client =
                                    new AWSECommerceServicePortTypeClient(_BasicHttpBinding, _EndPointAddress))
            {
                client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(AccessKeyId, SecretKey));

                return client.ItemSearch(itemSearch);
            }
        }
Example #55
0
        private void btnLivreAmazonRecherche_Click(object sender, EventArgs e)
        {
            ItemLookupResponse response;
            AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient("AWSECommerceServicePort");

            client.ChannelFactory.Endpoint.EndpointBehaviors.Add(
                new AmazonSigningEndpointBehavior(ConfigurationManager.AppSettings.Get("accessKeyId"),
                                                  ConfigurationManager.AppSettings.Get("secretKey")));

            ItemLookupRequest recherche_ISBN = new ItemLookupRequest();
            recherche_ISBN.SearchIndex = "Books";
            recherche_ISBN.ItemId = new string[] { txtISBN.Text };
            recherche_ISBN.IdType = ItemLookupRequestIdType.ISBN;
            recherche_ISBN.IdTypeSpecified = true;
            recherche_ISBN.ResponseGroup = new string[] { "Images", "Small" };

            ItemLookup itemlookup = new ItemLookup();
            itemlookup.Request = new ItemLookupRequest[] { recherche_ISBN };
            itemlookup.AWSAccessKeyId = ConfigurationManager.AppSettings.Get("accessKeyId");
            itemlookup.AssociateTag = ConfigurationManager.AppSettings.Get("associateTag");

            try
            {
                response = client.ItemLookup(itemlookup);

                foreach (var item in response.Items[0].Item)
                {
                    txtTitre.Text = item.ItemAttributes.Title;
                    txtAuteur.Text = item.ItemAttributes.Author[0];

                    // Create a web request to the URL for the picture
                    WebRequest webRequest = HttpWebRequest.Create(item.MediumImage.URL);

                    // Execute the request synchronuously
                    HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();

                    // Create an image from the stream returned by the web request
                    pictureBoxLivre.Image = new System.Drawing.Bitmap(webResponse.GetResponseStream());

                    WebClient clientWeb = new WebClient();
                    _cover = clientWeb.DownloadData(item.MediumImage.URL);

                    // Finally, close the request
                    webResponse.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #56
0
        public bool SearchForMovie(string movieName, int maxResults)
        {
            _locale = AmazonLocale.FromString(Properties.Settings.Default.AmazonLocale);

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

            client = new AWSECommerceServicePortTypeClient(
                binding, new EndpointAddress(_locale.URL)
            );

            client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior());

            try
            {
                ItemSearchRequest req = new ItemSearchRequest();
                req.SearchIndex = Properties.Settings.Default.AmazonSearchMode;
                req.Title = movieName;
                req.ItemPage = @"1";
                req.ResponseGroup = new string[] { "Medium", "Subjects" };

                ItemSearch iSearch = new ItemSearch();
                iSearch.Request = new ItemSearchRequest[] { req };
                iSearch.AWSAccessKeyId = Properties.Settings.Default.AWEAccessKeyId;

                ItemSearchResponse res = client.ItemSearch(iSearch);
                if (res.Items[0].Item.Length > 0)
                {
                    Item[] amazonItems = res.Items[0].Item;
                    int itemsToProcess = Math.Min(amazonItems.Length, maxResults);

                    if (amazonItems != null)
                    {
                        // convert Amazon Items to generic collection of DVDs
                        OMLSDKTitle[] searchResults = new OMLSDKTitle[itemsToProcess];

                        for (int i = 0; i < itemsToProcess; i++)
                        {
                            searchResults[i] = AmazonToOML.TitleFromAmazonItem(amazonItems[i]);
                        }
                        int totalPages = 0;
                        int totalItems = 0;
                        if (res.Items[0].TotalPages != null) totalPages = Convert.ToInt32(res.Items[0].TotalPages);
                        if (res.Items[0].TotalResults != null) totalItems = Convert.ToInt32(res.Items[0].TotalResults);

                        _searchResult = (new AmazonSearchResult(searchResults, totalPages, totalItems));
                    }
                    else
                    {
                        _searchResult = (new AmazonSearchResult(null, 0, 0));
                    }

                    return true;
                }
            }
            catch
            {
                _searchResult = (new AmazonSearchResult(null, 0, 0));
            }

            return false;
        }
Example #57
0
        static void Main(string[] args)
        {
            // Make the client
            AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient("AWSECommerceServicePort");
            client.ChannelFactory.Endpoint.EndpointBehaviors.Add(new AmazonSigningEndpointBehavior(access_key_id, secret_access_key));

            //var versions = GetAlternateVersions(client, "0441013074");
            //SaveObject(versions, "alternate_versions.txt");

            //GetVariations(client, "0441013074");

            var similar = SimilarityLookup(client, "0441013074");
            SaveObject(similar, "similar_0441013074.txt");

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
Example #58
0
        /// <summary>
        /// by UPC or ASIN
        /// </summary>
        /// <param name="product"></param>
        public static void Do(Product product)
        {
            // create a WCF Amazon ECS client
            AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient(
                new BasicHttpBinding(BasicHttpSecurityMode.Transport)
                    {
                        MaxReceivedMessageSize = int.MaxValue,
                        MaxBufferSize=int.MaxValue,
                        ReaderQuotas = new XmlDictionaryReaderQuotas()
                        {
                            MaxStringContentLength = int.MaxValue
                        }
                    },
                new EndpointAddress(DESTINATION));

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

            // prepare an ItemSearch request
            ItemLookup itemLookup = new ItemLookup();
            itemLookup.AWSAccessKeyId = MY_AWS_ID;
            itemLookup.AssociateTag = "modkitdesgui-20";

            ItemLookupRequest itemLookupRequest = new ItemLookupRequest();

            if (!string.IsNullOrEmpty(product.UPC))
            {
                itemLookupRequest.IdType = ItemLookupRequestIdType.UPC;
                itemLookupRequest.IdTypeSpecified = true;
                itemLookupRequest.ItemId = new[] { product.UPC };
            }
            else if (!string.IsNullOrEmpty(product.AmazonASIN))
            {
                itemLookupRequest.IdType = ItemLookupRequestIdType.ASIN;
                itemLookupRequest.IdTypeSpecified = true;
                itemLookupRequest.ItemId = new[] { product.AmazonASIN };
            }
            else
            {
                return;
            }

            itemLookupRequest.SearchIndex = "All";
            itemLookupRequest.ResponseGroup = new String[] { "Large" };
            itemLookup.Request = new ItemLookupRequest[] { itemLookupRequest };

            // make the call and print the title if it succeeds
            try
            {
                ItemLookupResponse itemLookupResponse = client.ItemLookup(itemLookup);
                //search by upc, it may return more than 1 items!!!

                if (itemLookupResponse.Items.Length == 0
                    || itemLookupResponse.Items[0].Item == null
                    || itemLookupResponse.Items[0].Item.Length == 0)
                    return;

                Item item = itemLookupResponse.Items[0].Item[0];
                foreach (Item ritem in itemLookupResponse.Items[0].Item)
                {
                    if (!string.IsNullOrEmpty(product.UPC) && ritem.ItemAttributes.UPC == product.UPC)
                    {
                        item = ritem;
                        break;
                    }
                }

                //
                if (item.ItemAttributes.Feature != null)
                    foreach (var feature in item.ItemAttributes.Feature)
                    {
                        product.Features.Add(new Feature() { Desc = feature });
                    }

                //
                product.AmazonDetailsUrl = item.DetailPageURL;
                int.TryParse(item.SalesRank, out product.AmazonSaleRank);
                product.AmazonASIN = item.ASIN;
                product.UPC = item.ItemAttributes.UPC;

                if (string.IsNullOrEmpty(product.Name))
                    product.Name = item.ItemAttributes.Title;

                if (item.ItemAttributes.ListPrice != null)
                {
                    decimal.TryParse(item.ItemAttributes.ListPrice.Amount, out product.AmazonPrice);
                }

                if (item.OfferSummary.LowestNewPrice != null)
                {
                    decimal lowestPrice;
                    if (decimal.TryParse(item.OfferSummary.LowestNewPrice.Amount, out lowestPrice)
                        && lowestPrice > 0)
                        product.AmazonPrice = lowestPrice;
                }
                product.AmazonPrice /= 100;

                if (string.IsNullOrEmpty(product.LargeImageUrl) || product.LargeImageUrl.Contains("default_hardlines"))
                    product.LargeImageUrl = item.LargeImage.URL;
                if (string.IsNullOrEmpty(product.ThumbnailImageUrl) || product.LargeImageUrl.Contains("default_hardlines"))
                    product.ThumbnailImageUrl = item.SmallImage.URL;

                //
                if (item.SimilarProducts != null)
                {
                    foreach (var similarProduct in item.SimilarProducts)
                    {
                        product.SimilarProducts.Add(new Product() { AmazonASIN = similarProduct.ASIN, Name = similarProduct.Title });
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Error("Amazon Error", e);
            }
        }
Example #59
0
        private static SimilarityLookupResponse SimilarityLookup(AWSECommerceServicePortTypeClient client, string asin)
        {
            var request = new SimilarityLookupRequest();
            request.ItemId = new string[] { asin };
            request.ResponseGroup = new string[] { "Large", "ItemAttributes" };

            var lookup = new SimilarityLookup();
            lookup.AWSAccessKeyId = access_key_id;
            lookup.AssociateTag = associate_tag;
            lookup.Request = new SimilarityLookupRequest[] { request };

            var response = client.SimilarityLookup(lookup);
            return response;
        }
    private string getImageURL(string asin)
    {
        const string accessKeyId = "AKIAINHOZEYXDKHXMYUQ";
        const string secretKey = "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";

        // create a WCF Amazon ECS client
        AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient(
            new BasicHttpBinding(BasicHttpSecurityMode.Transport),
            new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));

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

        // prepare an ItemSearch request
        ItemLookupRequest request = new ItemLookupRequest();
        request.ItemId = new string[] { asin };
        request.ResponseGroup = new string[] { "Images" };
        request.MerchantId = "Amazon";

        ItemLookup itemSearch = new ItemLookup();
        itemSearch.Request = new ItemLookupRequest[] { request };
        itemSearch.AWSAccessKeyId = accessKeyId;
        itemSearch.AssociateTag = "rgreuel-20";

        // issue the ItemSearch request
        ItemLookupResponse response = client.ItemLookup(itemSearch);

        Item returnedItem = response.Items[0].Item.First();

        return "<img src=\"" + returnedItem.MediumImage.URL + "\"/>";
    }