예제 #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            TiebaSignIn tiebaSignIn = new TiebaSignIn();
            string      kw          = context.Request.QueryString["kw"];
            string      bduss       = context.Request.QueryString["bduss"];

            if (string.IsNullOrEmpty(kw) || string.IsNullOrEmpty(bduss))
            {
                context.Response.Write("请在url中输入贴吧名和BDUSS");
            }
            else
            {
                SignInResult result = tiebaSignIn.DoSign_PCWeb(kw, bduss);

                JsonSerializerSettings settings = new JsonSerializerSettings();
                // 设置 对象转换为 json字符串时,属性名 小驼峰式转换
                settings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver();
                string jsonStr = JsonConvert.SerializeObject(result, settings);
                context.Response.Write(jsonStr);
            }
        }
예제 #2
0
 public void ProcessRequest(HttpContext context)
 {
     context.Response.ContentType = "application/json";
     if (!string.IsNullOrEmpty(context.Request.QueryString["bduss"]))
     {
         // 失败
         TiebaSignIn   tiebaSignIn = new TiebaSignIn();
         List <string> tiebaNames  = tiebaSignIn.GetFollowedTiebaNamesByBduss(context.Request.QueryString["bduss"]);
         string        jsonStr     = JsonConvert.SerializeObject(tiebaNames);
         context.Response.Write(jsonStr);
     }
     else if (!string.IsNullOrEmpty(context.Request.QueryString["userName"]))
     {
         // 成功
         TiebaSignIn   tiebaSignIn = new TiebaSignIn();
         List <string> tiebaNames  = tiebaSignIn.GetFollowedTiebaNames(context.Request.QueryString["userName"]);
         string        jsonStr     = JsonConvert.SerializeObject(tiebaNames);
         context.Response.Write(jsonStr);
     }
     else
     {
         context.Response.Write("请提供bduss或userName");
     }
 }