public static List <Deals> getSnapdealGetOffers() { List <Deals> lis = new List <Deals>(); WebClient wcSnapdeal = new WebClient(); Product lisSnapdeal = new Product(); wcSnapdeal.Headers.Add("Snapdeal-Affiliate-Id", "//Your Affiliate Id//"); wcSnapdeal.Headers.Add("Snapdeal-Token-Id", "//Your Affiliate Token//"); var SnapdealJson = wcSnapdeal.DownloadString("http://affiliate-feeds.snapdeal.com/feed/api/dod/offer"); try { JObject jObject = (JObject)JsonConvert.DeserializeObject(SnapdealJson); var jobject = jObject["products"]; var length = jObject["products"].Count(); for (int i = 0; i < length; i++) { Product p = new Product(); var o = jobject[i]["id"].ToString(); p = getSnapdealProductById(o); Deals d = new Deals(); d.id = o; d.title = p.title; d.imgurl_default = p.imgsrc; d.price = p.price.ToString(); d.url = p.url; d.category = p.productType; d.imgsrc = d.imgurl_default; d.website = p.website; lis.Add(d); d.Equals(null); } } catch { } return(lis); }
public static List <Deals> getAmazonOffers() { string NAMESPACE = "http://webservices.amazon.com/AWSECommerceService/2011-08-01"; SignedRequestHelper s = new SignedRequestHelper("//Your Associate Key Id //", "//Your Associate Secret Key //", "webservices.amazon.in"); IDictionary <string, string> r1 = new Dictionary <string, string>(); r1["Service"] = "AWSECommerceService"; r1["Operation"] = "ItemSearch"; r1["AssociateTag"] = "//Your Associate Tag "; r1["SearchIndex"] = "All"; r1["ResponseGroup"] = "Images,ItemAttributes,Offers,PromotionSummary"; r1["Keywords"] = " "; r1["Version"] = "2011-08-01"; // http://webservices.amazon.in/onca/xml?Service=AWSECommerceService // AssociateTag = buyhatk - 21 & //Product p = new Product(); string signedUrl = s.Sign(r1); WebRequest request = HttpWebRequest.Create(signedUrl); WebResponse response = request.GetResponse(); XmlDocument doc = new XmlDocument(); doc.Load(response.GetResponseStream()); var nsmgr = new XmlNamespaceManager(doc.NameTable); nsmgr.AddNamespace("app", "http://webservices.amazon.com/AWSECommerceService/2011-08-01"); List <Deals> lisAmazonOffer = new List <Deals>(); for (int i = 0; i < 9; i++) { Deals p = new Deals(); XmlNode idNode = doc.GetElementsByTagName("ASIN", NAMESPACE).Item(i); XmlNode productTypeNode = doc.GetElementsByTagName("ProductGroup", NAMESPACE).Item(i); XmlNode titleNode = doc.GetElementsByTagName("Title", NAMESPACE).Item(i); XmlNode ImageUrlNode = doc.GetElementsByTagName("ImageSets", NAMESPACE).Item(i); XmlNode priceNodeRaw = doc.GetElementsByTagName("LowestNewPrice", NAMESPACE).Item(i); XmlNode PRICENODE = priceNodeRaw.LastChild; XmlNode urlNode = doc.GetElementsByTagName("DetailPageURL", NAMESPACE).Item(i); XmlNode ImageNode = ImageUrlNode.FirstChild.LastChild.FirstChild; XmlNode priceNode = priceNodeRaw.FirstChild; p.id = idNode.InnerText; p.title = titleNode.InnerText; p.url = urlNode.InnerText; p.imgurl_default = ImageNode.InnerText; p.price = PRICENODE.InnerText; p.category = productTypeNode.InnerText; p.website = "Amazon"; p.imgsrc = p.imgurl_default; lisAmazonOffer.Add(p); p.Equals(null); } return(lisAmazonOffer); }