public void TestSearch()
    {
        AWSECommerceService service = new AWSECommerceService();

        //service.Url = "http://soap.amazon.com/onca/soap?Service=AWSECommerceService";
        service.Url = "http://localhost:8080/onca/soap?Service=AWSECommerceService";

        ItemSearchRequest search = new ItemSearchRequest();

        search.Keywords      = "television lcd";
        search.SearchIndex   = "Electronics";
        search.ResponseGroup = new string[] { "Large" };
        //OperationRequest
        ItemSearch request = new ItemSearch();

        request.Request        = new ItemSearchRequest[] { search };
        request.Validate       = "false";
        request.XMLEscaping    = "Single";
        request.SubscriptionId = DeveloperIds.AmazonID;
        ItemSearchResponse response = service.ItemSearch(request);

        Console.WriteLine(response.OperationRequest.ToString());
        if (response.Items.Length > 0)
        {
            Items[] arrayItems = response.Items;
            foreach (Items items in arrayItems)
            {
                foreach (Item item in items.Item)
                {
                    Console.WriteLine("Title (" + item.ItemAttributes.Title + ")");
                    Console.WriteLine("Item (" + item.ASIN + ")");
                }
            }
        }
    }
        public override void Process(OutputStream <Item> output)
        {
            AWSECommerceService service = new AWSECommerceService();

            //service.Url = "http://soap.amazon.com/onca/soap?Service=AWSECommerceService";
            service.Url = "http://localhost:8080/onca/soap?Service=AWSECommerceService";

            ItemSearchRequest search = new ItemSearchRequest();

            search.Keywords      = _keywords + " tv";
            search.SearchIndex   = "Electronics";
            search.ResponseGroup = new string[] { "Large" };
            ItemSearch request = new ItemSearch();

            request.Request        = new ItemSearchRequest[] { search };
            request.Validate       = "false";
            request.XMLEscaping    = "Single";
            request.SubscriptionId = DeveloperIds.AmazonID;
            ItemSearchResponse response = service.ItemSearch(request);

            Console.WriteLine(response.OperationRequest.ToString());
            if (response.Items.Length > 0)
            {
                Items[] arrayItems = response.Items;
                foreach (Items items in arrayItems)
                {
                    foreach (Item item in items.Item)
                    {
                        output.Write(item);
                    }
                }
            }
        }
        public ItemLookupResponse Lookup(ItemLookupRequest lookupRequest)
        {
            ItemLookup          lookup   = CreateItemLookup(lookupRequest);
            AWSECommerceService api      = GetService();
            ItemLookupResponse  response = api.ItemLookup(lookup);

            return(response);
        }
        public ItemSearchResponse GetSearchResponse(ItemSearchRequest searchRequest)
        {
            ItemSearch search = CreateItemSearch(searchRequest);

            AWSECommerceService api      = GetService();
            ItemSearchResponse  response = api.ItemSearch(search);

            return(response);
        }
        public void GetSearchResponseAsync(ItemSearchRequest searchRequest, ItemSearchCompletedEventHandler callback)
        {
            ItemSearch search = CreateItemSearch(searchRequest);

            AWSECommerceService api = GetService();

            api.ItemSearchCompleted += callback;
            api.ItemSearchAsync(search);
        }
    // perform the Amazon search with SOAP and return results as a DataTable
    public static DataTable GetAmazonDataWithSoap()
    {
        // Create Amazon objects
        AWSECommerceService amazonService     = new AWSECommerceService();
        ItemSearch          itemSearch        = new ItemSearch();
        ItemSearchRequest   itemSearchRequest = new ItemSearchRequest();
        ItemSearchResponse  itemSearchResponse;

        // Setup Amazon objects
        itemSearch.SubscriptionId       = BalloonShopConfiguration.SubscriptionId;
        itemSearchRequest.Keywords      = BalloonShopConfiguration.SearchKeywords;
        itemSearchRequest.SearchIndex   = BalloonShopConfiguration.SearchIndex;
        itemSearchRequest.ResponseGroup =
            BalloonShopConfiguration.ResponseGroups.Split(',');
        itemSearch.Request = new AmazonEcs.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 (AmazonEcs.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);
    }
        protected AWSECommerceService GetService()
        {
            ValidateAmazonSecurity();
            AWSECommerceService api = new AWSECommerceService();

            api.Destination = new Uri(DESTINATION);
            AmazonHmacAssertion amazonHmacAssertion = new AmazonHmacAssertion(AWSKeyID, AWSSecretKey);

            api.SetPolicy(amazonHmacAssertion.Policy());
            return(api);
        }
Exemplo n.º 8
0
    // perform the Amazon search with SOAP and return results as a DataTable
    public static DataTable GetAmazonDataWithSoap()
    {
        // Create Amazon objects
        AWSECommerceService amazonService = new AWSECommerceService();
        ItemSearch itemSearch = new ItemSearch();
        ItemSearchRequest itemSearchRequest = new ItemSearchRequest();
        ItemSearchResponse itemSearchResponse;
        // Setup Amazon objects
        itemSearch.SubscriptionId = BalloonShopConfiguration.SubscriptionId;
        itemSearchRequest.Keywords = BalloonShopConfiguration.SearchKeywords;
        itemSearchRequest.SearchIndex = BalloonShopConfiguration.SearchIndex;
        itemSearchRequest.ResponseGroup =
        BalloonShopConfiguration.ResponseGroups.Split(',');
        itemSearch.Request = new AmazonEcs.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 (AmazonEcs.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;
    }
Exemplo n.º 9
0
    public static void Main()
    {
        aws = new AWSECommerceService();

        Regex regexp = new Regex(@"\./(?<xiba>([^\.]+))");

        foreach(string file in Directory.GetFiles("./"))
        {
            MatchCollection matches = regexp.Matches(file);

            foreach(Match match in matches)
            {
                SearchForBook(match.Groups["xiba"].ToString());
            }
        }
    }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            // If you are using a debugging proxy like Fiddler to capture SOAP
            // envelopes, and you get SSL Certificate warnings, uncomment the
            // following line:
            // ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

            // Create an ItemLookup request, with ResponseGroup "Small"
            // and using the item ID provided above.
            ItemLookup itemLookup = new ItemLookup();

            itemLookup.AWSAccessKeyId = MY_AWS_ID;

            ItemLookupRequest itemLookupRequest = new ItemLookupRequest();

            itemLookupRequest.ItemId        = new String[] { ITEM_ID };
            itemLookupRequest.ResponseGroup = new String[] { "Small", "AlternateVersions" };
            itemLookup.Request = new ItemLookupRequest[] { itemLookupRequest };

            // create an instance of the serivce
            AWSECommerceService api = new AWSECommerceService();

            // set the destination
            api.Destination = new Uri(DESTINATION);

            // apply the security policy, which will add the require security elements to the
            // outgoing SOAP header
            AmazonHmacAssertion amazonHmacAssertion = new AmazonHmacAssertion(MY_AWS_ID, MY_AWS_SECRET);

            api.SetPolicy(amazonHmacAssertion.Policy());

            // make the call and print the title if it succeeds
            try
            {
                ItemLookupResponse itemLookupResponse = api.ItemLookup(itemLookup);
                Item item = itemLookupResponse.Items[0].Item[0];
                System.Console.WriteLine(item.ItemAttributes.Title);
            }
            catch (Exception e)
            {
                System.Console.Error.WriteLine(e);
            }

            // we're done
            System.Console.WriteLine("HMAC sample finished. Hit Enter to terminate.");
            System.Console.ReadLine();
        }
        static void Main(string[] args)
        {
            // If you are using a debugging proxy like Fiddler to capture SOAP
            // envelopes, and you get SSL Certificate warnings, uncomment the
            // following line:
            // ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

            // create an ItemLookup request:
            ItemLookup itemLookup = new ItemLookup();

            itemLookup.AWSAccessKeyId = MY_AWS_ACCESS_KEY_ID;

            ItemLookupRequest itemLookupRequest = new ItemLookupRequest();

            itemLookupRequest.ItemId        = new String[] { "0545010225" };
            itemLookupRequest.ResponseGroup = new String[] { "Small", "AlternateVersions" };
            itemLookup.Request = new ItemLookupRequest[] { itemLookupRequest };

            // create service instance and set destination
            AWSECommerceService api = new AWSECommerceService();

            api.Destination = new Uri(DESTINATION);

            // set the policy so that all outgoing requests are signed with the certificate
            AmazonX509Assertion amazonX509Assertion = new AmazonX509Assertion(MY_AWS_CERT_NAME);

            api.SetPolicy(amazonX509Assertion.Policy());

            // fetch the response.
            ItemLookupResponse itemLookupResponse = api.ItemLookup(itemLookup);

            Item item = null;

            try {
                item = itemLookupResponse.Items[0].Item[0];
                System.Console.WriteLine(item.ItemAttributes.Title);
            } catch (Exception e) {
                System.Console.Error.WriteLine(e);
            }

            System.Console.WriteLine("X.509 sample finished. Hit Enter to terminate.");
            System.Console.ReadLine();
        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("AmazonTest [keyword]");
                return;
            }

            AWSECommerceService service = new AWSECommerceService();

            ItemSearchRequest req = new ItemSearchRequest();

            req.Keywords      = args[0];
            req.SearchIndex   = "Books";
            req.ResponseGroup = new string[] { "ItemAttributes" };
            req.ItemPage      = "1";

            ItemSearch search = new ItemSearch();

            search.AWSAccessKeyId = "xxx";
            search.Request        = new ItemSearchRequest[] { req };

            ItemSearchResponse res = service.ItemSearch(search);

            if (res.Items[0].Request.Errors != null)
            {
                Console.WriteLine("error:{0}", res.Items[0].Request.Errors[0].Message);
            }

            if (res.Items[0].Item != null)
            {
                foreach (Item item in res.Items[0].Item)
                {
                    Console.WriteLine("title:{0}", item.ItemAttributes.Title);
                }
            }
        }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("AmazonTest [keyword]");
                return;
            }

            AWSECommerceService service = new AWSECommerceService();

            ItemSearchRequest req = new ItemSearchRequest();
            req.Keywords = args[0];
            req.SearchIndex = "Books";
            req.ResponseGroup = new string[] {"ItemAttributes"};
            req.ItemPage = "1";

            ItemSearch search = new ItemSearch();
            search.AWSAccessKeyId = "xxx";
            search.Request = new ItemSearchRequest[] { req };

            ItemSearchResponse res = service.ItemSearch(search);

            if (res.Items[0].Request.Errors != null)
            {
                Console.WriteLine("error:{0}", res.Items[0].Request.Errors[0].Message);
            }

            if (res.Items[0].Item != null)
            {
                foreach (Item item in res.Items[0].Item)
                {
                    Console.WriteLine("title:{0}", item.ItemAttributes.Title);
                }
            }
            
        }
Exemplo n.º 14
0
        protected override Id3Tag[] GetTagInfo(Id3Tag tag)
        {
            var request = new ItemSearchRequest {
                SearchIndex   = "Music",
                Keywords      = tag.Artists.Value + " " + tag.Title.Value,
                ResponseGroup = new[] { "Small", "Images" }
            };

            var itemSearch = new ItemSearch {
                AWSAccessKeyId = "1YY0CZVHA1BX3BEV5H82",
                AssociateTag   = "knanamusin-20",
                Request        = new[] { request }
            };

            ItemSearchResponse response;
            var service = new AWSECommerceService();

            try
            {
                response = service.ItemSearch(itemSearch);
            }
            catch (SoapException)
            {
                return(Id3Tag.Empty);
            }
            finally
            {
                service.Dispose();
            }

            if (response == null || response.Items == null || response.Items.Length == 0)
            {
                return(Id3Tag.Empty);
            }
            Item[] items = response.Items[0].Item;
            if (items == null || items.Length == 0)
            {
                return(Id3Tag.Empty);
            }

            var results = new List <Id3Tag>(items.Length);

            foreach (Item item in items)
            {
                var result = new Id3Tag();
                result.Album.Value = item.ItemAttributes.Title;
                IList <string> artists;
                if (item.ItemAttributes.Artist == null || item.ItemAttributes.Artist.Length == 0)
                {
                    artists = tag.Artists.Value;
                }
                else
                {
                    artists = item.ItemAttributes.Artist;
                }
                foreach (string artist in artists)
                {
                    result.Artists.Value.Add(artist);
                }
                result.Publisher.Value = item.ItemAttributes.Manufacturer;
                result.PaymentUrl.Url  = item.DetailPageURL;

                if (item.LargeImage != null)
                {
                    PictureFrame picture = Utility.GetPicture(item.LargeImage.URL);
                    if (picture != null)
                    {
                        result.Pictures.Add(picture);
                    }
                }

                if (item.MediumImage != null)
                {
                    PictureFrame picture = Utility.GetPicture(item.MediumImage.URL);
                    if (picture != null)
                    {
                        result.Pictures.Add(picture);
                    }
                }

                if (item.SmallImage != null)
                {
                    PictureFrame picture = Utility.GetPicture(item.SmallImage.URL);
                    if (picture != null)
                    {
                        result.Pictures.Add(picture);
                    }
                }

                results.Add(result);
            }

            return(results.ToArray());
        }
Exemplo n.º 15
0
        public void Search(string searchtag)
        {
            if (searchtag == null)
            {
                return;
            }
            if (searchtag == string.Empty)
            {
                return;
            }
            m_imageList.DisposeAndClearList();
            AWSECommerceService amazonService     = new AWSECommerceService();
            ItemSearch          itemSearch        = new ItemSearch();
            ItemSearchRequest   itemSearchRequest = new ItemSearchRequest();
            ItemSearchResponse  itemSearchResponse;

            itemSearch.SubscriptionId       = "1CTB4YKNPBV7EK9SQVG2";
            itemSearch.AssociateTag         = "";
            itemSearchRequest.Keywords      = searchtag;
            itemSearchRequest.SearchIndex   = "DVD";
            itemSearchRequest.ResponseGroup = new string[] { "Large", "Images", "ItemAttributes", "OfferFull" };
            itemSearchRequest.ItemPage      = "1";
            itemSearch.Request = new ItemSearchRequest[1] {
                itemSearchRequest
            };
            //send the query
            try
            {
                itemSearchResponse = amazonService.ItemSearch(itemSearch);
            }
            catch (Exception)
            {
                return;
            }

            Items[] itemsResponse = itemSearchResponse.Items;
            if (itemsResponse == null)
            {
                return;
            }
            for (int i = 0; i < itemsResponse.Length; ++i)
            {
                Items itemList = itemsResponse[i];
                if (itemList == null)
                {
                    continue;
                }
                if (itemList.Item == null)
                {
                    continue;
                }

                for (int x = 0; x < itemList.Item.Length; ++x)
                {
                    Item item = itemList.Item[x];
                    if (item == null)
                    {
                        continue;
                    }
                    Image image = item.LargeImage;
                    if (image != null)
                    {
                        if (image.URL != null && image.URL.Length > 0)
                        {
                            m_imageList.Add(image.URL);
                        }
                    }
                }
            }
        }
        private void GetInfoFromISBN(string isbn, string technology)
        {
            if (isbn.Length != 10)
            {
                return;
            }

//		MultiOperation commerceService = new MultiOperation();

            AWSECommerceService commerceService = null;

            try
            {
                commerceService = new AWSECommerceService();
            }
            catch (Exception e)
            {
                lblStatus.Text = e.Message;
            }
            // AWSProductData productData = new AWSProductData();
            ItemLookup lookup = null;

            try
            {
                ItemLookupRequest req = new ItemLookupRequest();
                req.IdType    = ItemLookupRequestIdType.ASIN;
                req.ItemId    = new string[1];
                req.ItemId[0] = isbn;
                // req.SearchIndex = "Books";

                lookup = new ItemLookup();
                lookup.AssociateTag   = "libertyassocia00A";
                lookup.SubscriptionId = "0SD959SZV6KXV3BKE2R2";
                lookup.Request        = new ItemLookupRequest[1];
                lookup.Request[0]     = req;
            }
            catch (System.Exception e)
            {
                lblStatus.Text = e.Message;
            }


            ItemLookupResponse response;
            Items info;

            Item[] items;
            Item   item;



            int    salesRank = -1;
            string author    = string.Empty;
            string pubDate   = string.Empty;
            string publisher = string.Empty;
            string title     = string.Empty;
            string strURL    = string.Empty;

            try
            {
                response = commerceService.ItemLookup(lookup);
                // response = productData.ItemLookup( lookup );
                info      = response.Items[0];
                items     = info.Item;
                item      = items[0];
                salesRank = item.SalesRank == null ? -1 : Convert.ToInt32(item.SalesRank);
                author    = FixQuotes(item.ItemAttributes.Author[0]);
                pubDate   = FixQuotes(item.ItemAttributes.PublicationDate);
                publisher = FixQuotes(item.ItemAttributes.Publisher);
                title     = FixQuotes(item.ItemAttributes.Title);
                strURL    = item.DetailPageURL;
            }
            catch (System.Exception ex)
            {
                lblStatus.Text = ex.Message;
            }

            // update the list box
            string results = title + " by " + author + ": " +
                             publisher + ", " + pubDate + ". Rank: " + salesRank;

            lbOutput.Items.Add(results);
            lbOutput.SelectedIndex = lbOutput.Items.Count - 1;

            // update the database
            string commandString = @"Update BookInfo set isbn = '" +
                                   isbn + "', title = '" + title + "', publisher = '" +
                                   publisher + "', pubDate = '" + pubDate + "', rank = " +
                                   salesRank + ", link = '" + strURL + "', lastUpdate = '" +
                                   System.DateTime.Now + "', technology = '" +
                                   technology + "', author = '" +
                                   author + "' where isbn = '" +
                                   isbn + "'";

            command.CommandText = commandString;
            try
            {
                // if no rows were affected, this is a new record
                connection.Open();
                int numRowsAffected = command.ExecuteNonQuery();
                if (numRowsAffected == 0)
                {
                    commandString = @"Insert into BookInfo values ('" +
                                    isbn + "', '" + title + "', '" + publisher + "', '" +
                                    pubDate + "', '" + FixQuotes(strURL) + "', " + salesRank + ", '" +
                                    System.DateTime.Now +
                                    "', '" + technology + "', '" + author + "')";

                    command.CommandText = commandString;
                    command.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                lblStatus.Text = ex.Message;
                lbOutput.Items.Add("Unable to update database!");
                lbOutput.SelectedIndex = lbOutput.Items.Count - 1;
            }
            finally
            {
                connection.Close(); // clean up
            }
        }                           // close for GetInfoFromISBN
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            AWSECommerceService Service = new AWSECommerceService();

            ItemSearch        itemSearch = new ItemSearch();
            ItemSearchRequest request    = new ItemSearchRequest();

            // Keys
            itemSearch.AWSAccessKeyId = "";                 // YOUR ACCESS KEY!
            itemSearch.AssociateTag   = "meinkleinerbl-21"; // YOUR ASSOCIATE TAG!

            // Suchbereich eingrenzen
            request.ResponseGroup = new string[] { "Medium", "Offers" };
            request.SearchIndex   = "Blended";
            request.Keywords      = "Potter"; // Suchwort

            request.ItemPage = "1";
            request.Count    = "25"; // Maximum per Page

            itemSearch.Request = new ItemSearchRequest[] { request };

            try
            {
                ItemSearchResponse response = Service.ItemSearch(itemSearch);

                Items[] itemsArray = response.Items;

                foreach (Items items in itemsArray)
                {
                    Console.WriteLine("Total Pages; " + items.TotalPages);
                    Console.WriteLine("Total Results; " + items.TotalResults);

                    if (items != null)
                    {
                        if (items.Item != null)
                        {
                            for (int i = 0; i < items.Item.Length; i++)
                            {
                                Console.WriteLine();
                                Console.WriteLine("Title: " + items.Item[i].ItemAttributes.Title);

                                if (items.Item[i].Offers.TotalOffers != "0")
                                {
                                    if (items.Item[i].Offers.Offer[0].OfferListing[0].Price != null)
                                    {
                                        Console.WriteLine("Price: " + items.Item[i].Offers.Offer[0].OfferListing[0].Price.FormattedPrice);
                                    }
                                }
                                Console.WriteLine("SalesRank: " + items.Item[i].SalesRank);
                                Console.WriteLine("SalesRank: " + items.Item[i].ASIN);
                                Console.WriteLine("Description: " + items.Item[i].ItemAttributes.Label);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.ReadLine();
        }
Exemplo n.º 18
0
        // Appends itemsPage items to the results list.
        protected int ProcessPage(IList<AzResultViewModel> results, AWSECommerceService.Items itemsPage, int iStart, int iEnd)
        {
            int nItemsProcessed = 0;

            if (itemsPage.Item != null)
            {
                iEnd = Math.Min(iEnd, itemsPage.Item.Length);

                for (int i = iStart; i < iEnd; i++)
                {
                    var item = itemsPage.Item[i];
                    AzResultViewModel result = new AzResultViewModel();
                    result.title = item.ItemAttributes.Title;
                    int price = -1;
                    if (item.ItemAttributes.ListPrice != null)
                    {
                        Int32.TryParse(item.ItemAttributes.ListPrice.Amount, out price);
                    }
                    result.price = price;
                    if (item.ImageSets != null)
                    {
                        result.imageUrl = item.ImageSets[0].MediumImage.URL;
                    }
                    result.amazonUrl = item.DetailPageURL;
                    results.Add(result);

                    nItemsProcessed++;
                }
            }

            return nItemsProcessed;
        }