using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.IO;
using System.Net;
namespace ConsoleApp11
{
class Program
{
static void Main(string[] args)
{
string rfcontent = “”;
string starttkl = “【高腰牛仔裤女春秋新款显瘦显高显腿长紧身小脚铅笔waitmore裤子潮】,椱ァ製这句话₳cstOYFZWG80₳后咑閞淘宀┡ē”;
//通过淘口令获取商品id
string url = “http://api.tbk.dingdanxia.com/tkl/query?apikey=C91fexMiR0ioCxwT1dtbxbOrLZqjxbXp&tkl=”+ starttkl + “&signature=1”;
//Get请求
HttpWebResponse w = HttpHelper.CreateGetHttpResponse(url, 30000, null, null);
StreamReader sr = new StreamReader(w.GetResponseStream());
string/这是Json字符串/ jsonstr = sr.ReadToEnd();
test obj = JsonConvert.DeserializeObject(jsonstr);
string num_iid = obj.data.num_iid;
rfcontent += obj.data.content;
//通过商品id获取优惠券clickurl
string url1 = "https://api.taokouling.com/tkl/TbkPrivilegeGet?apikey=eByYtkPrKH&itemid="+ num_iid + "&siteid=318400026&adzoneid=86733350131&uid=3334885687";
//Get请求
HttpWebResponse w1 = HttpHelper.CreateGetHttpResponse(url1, 30000, null, null);
StreamReader sr1 = new StreamReader(w1.GetResponseStream());
string/*这是Json字符串*/ jsonstr1 = sr1.ReadToEnd();
test2 obj1 = JsonConvert.DeserializeObject<test2>(jsonstr1);
string clickurl =obj1.result.data.coupon_click_url;
rfcontent += obj1.result.data.coupon_info;
//通过url生成新的淘口令
string url2 = "https://api.taokouling.com/tkl/Tbktbtaokouling?apikey=eByYtkPrKH&url="+ clickurl + "&traceId=0b0ffd8515732987739525038e&union_lens=lensId:0b0f79e2_0c71_16e4fea1fdb_8381&xId=AklOXk5NS7Flyi4oonG9iuEMs1BcSb4BK4DMg4HN8RtJgU8sFDhzNtm7DAB1NvStIV1LqGJPhVzhjnLIa7Hl1d&text=满减优惠活动&pic=''";
//Get请求
HttpWebResponse w2 = HttpHelper.CreateGetHttpResponse(url2, 30000, null, null);
StreamReader sr2 = new StreamReader(w2.GetResponseStream());
string/*这是Json字符串*/ jsonstr2 = sr2.ReadToEnd();
test5 obj2 = JsonConvert.DeserializeObject<test5>(jsonstr2);
string tkl = obj2.tkl;
Console.WriteLine(rfcontent+" "+tkl);
}
}
public class test {
public string code { get; set; }
public string msg { get; set; }
public test1 data { get; set; }
}
public class test1 {
public string content { get; set; }
public string native_url { get; set; }
public string pic_url { get; set; }
public string price { get; set; }
public string suc { get; set; }
public string thumb_pic_url { get; set; }
public string title { get; set; }
public string url { get; set; }
public string request_id { get; set; }
public string num_iid { get; set; }
}
public class test2 {
public test3 result { get; set; }
public string request_id { get; set; }
}
public class test3 {
public test4 data { get; set; }
}
public class test4 {
public string category_id { get; set; }
public string coupon_click_url { get; set; }
public string coupon_end_time { get; set; }
public string coupon_info { get; set; }
public string coupon_remain_count { get; set; }
public string coupon_start_time { get; set; }
public string coupon_total_count { get; set; }
public string coupon_type { get; set; }
public string item_id { get; set; }
public string item_url { get; set; }
public string max_commission_rate { get; set; }
}
public class test5 {
public string tkl { get; set; }
public string url { get; set; }
public string jb { get; set; }
public string code { get; set; }
public string msg { get; set; }
}
}