Esempio n. 1
0
        /// <summary>
        /// Searches for one item
        /// </summary>
        /// <param name="status">Search string</param>
        /// <returns>ASIN of first item</returns>
        public static string[] SearchItems(string status, string searchIndex, string[] amazonDetails, string amazonLocaleApiUrl)
        {
            IDictionary <string, string> r1 = new Dictionary <string, String>();

            r1["Service"]   = "AWSECommerceService";
            r1["Version"]   = "2011-08-01";
            r1["Operation"] = "ItemSearch";

            if (searchIndex.Equals("Music"))
            {
                string[] songInfo = status.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                r1["Artist"]      = songInfo[0];
                r1["Title"]       = songInfo[1];
                r1["SearchIndex"] = searchIndex;
            }
            else if (searchIndex.StartsWith("TV"))
            {
                r1["Keywords"] = HttpUtility.HtmlEncode(status.Replace('.', ' ').Replace('-', ' '));

                //string durationString = searchIndex.Substring(searchIndex.IndexOf('|') + 1);

                //if (!string.IsNullOrEmpty(durationString))
                //{
                //    int duration = int.Parse(durationString);

                //    if (duration < 3600)
                //    {
                //        r1["BrowseNode"] = GetTelevisionBrowseNodeId(amazonLocaleApiUrl);
                //    }
                //}

                r1["SearchIndex"] = "DVD";
            }
            else
            {
                r1["Keywords"]    = HttpUtility.HtmlEncode(status.Replace('.', ' ').Replace('-', ' '));
                r1["SearchIndex"] = searchIndex;
            }

            r1["ResponseGroup"] = "Small";
            r1["AssociateTag"]  = GetAssociateTag(amazonLocaleApiUrl);

            SignedRequestHelper helper = new SignedRequestHelper(MY_AWS_ACCESS_KEY_ID, amazonLocaleApiUrl);

            string requestUrl = helper.Sign(r1);

            return(FetchItem(requestUrl, amazonDetails));
        }
Esempio n. 2
0
        public static string[] LookupItem(string[] amazonDetails, string amazonLocaleUrl)
        {
            IDictionary <string, string> r1 = new Dictionary <string, String>();

            r1["Service"]       = "AWSECommerceService";
            r1["Version"]       = "2011-08-01";
            r1["Operation"]     = "ItemLookup";
            r1["ItemId"]        = amazonDetails[4];
            r1["ResponseGroup"] = "Reviews,Images";
            r1["AssociateTag"]  = GetAssociateTag(amazonLocaleUrl);

            SignedRequestHelper helper = new SignedRequestHelper(MY_AWS_ACCESS_KEY_ID, amazonLocaleUrl);

            string requestUrl = helper.Sign(r1);

            return(FetchItemDetails(requestUrl, amazonDetails));
        }