/// <summary>
        /// 物料传播方式获取,输入一个原始的链接,转换得到指定的传播方式,如二维码,淘口令,短连接; 现阶段只支持短链接。
        /// </summary>
        /// <param name="sourceUrl">原始的链接</param>
        /// <returns></returns>
        public string taobao_tbk_spread_get(string sourceUrl, string _appkey, string _appsecret)
        {
            try
            {
                ITopClient          client = new DefaultTopClient(url, string.IsNullOrEmpty(_appkey) ? appkey : _appkey, string.IsNullOrEmpty(_appsecret) ? appsecret : _appsecret);
                TbkSpreadGetRequest req    = new TbkSpreadGetRequest();

                List <TbkSpreadGetRequest.TbkSpreadRequestDomain> requests = new List <TbkSpreadGetRequest.TbkSpreadRequestDomain>();

                TbkSpreadGetRequest.TbkSpreadRequestDomain obj3 = new TbkSpreadGetRequest.TbkSpreadRequestDomain();
                requests.Add(obj3);
                obj3.Url      = sourceUrl;
                req.Requests_ = requests;

                TbkSpreadGetResponse response = client.Execute(req);
                if (!response.IsError)
                {
                    return(response.Results[0].Content);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Log(string.Format("taobao_tbk_spread_get:{0},{1}", ex.Message, ex.StackTrace));
            }

            return("");
        }
Exemple #2
0
        public static string GetTbkShortUrl(string tbkurl)
        {
            //tbkurl= "https://uland.taobao.com/coupon/edetail?activityId=cca299fffaee4c45bbfa541ac208dd16&pid=mm_122033678_24252915_81212616&itemId=547482547612&src=fklm_hltk&dx=1";
            string url = "http://gw.api.taobao.com/router/rest";

            ITopClient client = new DefaultTopClient(url, Alimama.appkey, Alimama.secret);

            TbkSpreadGetRequest req = new TbkSpreadGetRequest();
            List <TbkSpreadGetRequest.TbkSpreadRequestDomain> list2 = new List <TbkSpreadGetRequest.TbkSpreadRequestDomain>();

            TbkSpreadGetRequest.TbkSpreadRequestDomain obj3 = new TbkSpreadGetRequest.TbkSpreadRequestDomain();
            list2.Add(obj3);
            obj3.Url      = tbkurl;
            req.Requests_ = list2;
            TbkSpreadGetResponse rsp1 = client.Execute(req);
            string tbkshorturl        = "";

            HttpHelper1.GetStringInTwoKeyword(rsp1.Body, ref tbkshorturl, "<content>", "</content>", 0);
            return(tbkshorturl);
        }
Exemple #3
0
        public static List <string> PostQuans(string q, long PageNo)
        {
            List <string> ReturnInfos = new List <string>();
            string        serverUrl   = "http://gw.api.taobao.com/router/rest";
            string        appkey      = "24984684";
            string        secret      = "b52c6c517d488ca9ccb95411daede241";
            long          adzonrid    = 11262850424L;
            ITopClient    client      = new DefaultTopClient(serverUrl, appkey, secret);
            //调用好券清单API,返回一个列表
            TbkDgItemCouponGetRequest GetReq = new TbkDgItemCouponGetRequest();

            GetReq.AdzoneId = adzonrid;
            GetReq.Platform = 1;
            GetReq.PageSize = 15L;
            GetReq.Q        = q;
            GetReq.PageNo   = PageNo;
            TbkDgItemCouponGetResponse GetRsp = client.Execute(GetReq);     //获取一个结果列表

            foreach (var item in GetRsp.Results)
            {
                //获取每个宝贝的现价、优惠价
                TbkItemInfoGetRequest InfoReq = new TbkItemInfoGetRequest();
                InfoReq.NumIids  = item.NumIid.ToString();
                InfoReq.Platform = 1;
                TbkItemInfoGetResponse InfoRsp = client.Execute(InfoReq);

                //生成淘口令
                TbkTpwdCreateRequest TpwdReq = new TbkTpwdCreateRequest();
                TpwdReq.Text = item.Title;
                TpwdReq.Url  = item.CouponClickUrl;
                TpwdReq.Logo = item.PictUrl;
                TbkTpwdCreateResponse TpwdRsp = client.Execute(TpwdReq);

                //淘口令短链接
                TbkSpreadGetRequest SpreadReq = new TbkSpreadGetRequest();
                List <TbkSpreadGetRequest.TbkSpreadRequestDomain> urls       = new List <TbkSpreadGetRequest.TbkSpreadRequestDomain>();
                TbkSpreadGetRequest.TbkSpreadRequestDomain        native_url = new TbkSpreadGetRequest.TbkSpreadRequestDomain();
                urls.Add(native_url);
                native_url.Url      = item.CouponClickUrl;
                SpreadReq.Requests_ = urls;
                TbkSpreadGetResponse SpreadRsp = client.Execute(SpreadReq);

                if (SpreadRsp.Results.FirstOrDefault().ErrMsg == "OK")
                {
                    //拼接字符串:商品标题,图片,现价,折后价,下单链接,淘口令
                    string Detail_Info = string.Empty;
                    Detail_Info += string.Format("【{0}】\n", item.Title);
                    Detail_Info += string.Format("[CQ:emoji,id=128073]{0}\n", item.ItemDescription);
                    Detail_Info += string.Format("[CQ:image,file={0}]\n", item.PictUrl);
                    Detail_Info += string.Format("现价:¥{0}\n", item.ZkFinalPrice);
                    Detail_Info += string.Format("券后价:¥{0}\n", ZHPrice(item.ZkFinalPrice, item.CouponInfo));
                    Detail_Info += string.Format("【领券下单链接】{0}", SpreadRsp.Results.FirstOrDefault().Content);
                    Detail_Info += string.Format("点击链接,再选择浏览器打开,或者复制这段描述{0}后到淘宝", TpwdRsp.Data.Model);
                    ReturnInfos.Add(Detail_Info);
                }
                else
                {
                    continue;
                }
            }

            return(ReturnInfos);
        }