本帖最后由 xz_whist 于 2015-3-22 21:52 编辑
超级郁闷呀,用post方式提交数据后,服务器返回成功的标志了,但后续的操作无法进行了
[JavaScript] 纯文本查看 复制代码 {"status":"success","info":{"name":"\u5a01\u950b\u7f51\u8bba\u575b","link":"http:\/\/bbs.feng.com\/","wait":2000,"syn_str":"<script type=\"text\/javascript\" src=\"http:\/\/bbs.feng.com\/api\/uc.php?time=1426864865&code=66944VKvQSGUhnlrWyeImCK0zBQwzkDDc5uow4qTlnNGtzPGP2DsFLAdzUp4l2TwmARshIRQhUtsnxDENIZqnp5EchdEX5fqz9Hjy%2B5BU3a%2F9LdLw7IJZ0vJ9HMsE8W51WsoexE5xt9DFsqfVj%2F7fo0is9LuwHM0xhBbl9lUF1KUvmnTQDmTjHajkiqrlNu%2FnZCYzOkUNpXR0vK%2BVHgWRcSrs5XZRVFiKK2OmuOl74AvfaG4QsFa3gLFBaJYiKx48HQXBtApkDgSMoVb9ljEU01LCJg88GiUDr3gSE1LrRR%2BC479xtfvW8PbuiQbtUqqMWDuuULqP2b7o6ch1XB00gks%2FKCTYY4gLyTDF5HDKmYEO%2Bu3WiK95J%2BN4GUZAKkWrJSC5i6H3DzCCizqUMevqctZRLFCsx%2BeK%2BRAXPSUqg\" reload=\"1\"><\/script>"}}
返回json ,状态:success 说明post是成功的,然后保存这步的cookies, 用作下一步获取个人的信息,却发现还是xian未登陆
//操作的流程
1、登陆前的cookie获取
[C#] 纯文本查看 复制代码 HttpItemObj = new HttpItem();
HttpHelperObj = new HttpHelper();
HttpResultObj = new HttpResult();
HttpItemObj.Method = "GET";
//登陆窗口的链接
HttpItemObj.URL = "http://passport.feng.com/?r=user/login&sso%5Bjump%5D=http%3A%2F%2Fbbs.feng.com%2F&sso%5Bname%5D=%E5%A8%81%E9%94%8B%E8%AE%BA%E5%9D%9B&sso%5Bapps%5D=2&sso%5Bverify%5D=7a928982dd59b02a3024858bd61ccf22";
HttpItemObj.Referer = "bbs.feng.com";
HttpResultObj = HttpHelperObj.GetHtml(HttpItemObj);
cookies = HttpResultObj.Cookie;
string htmltext = HttpResultObj.Html;
//取得页面上隐藏的 v_token的值,后面post登陆要用到
strV_token = HtmlHelper.GetWfLoginV_token(htmltext);
2、输入用户名密码后开始登陆,第一次如果用户名密码正确,不需要输入验证码
[C#] 纯文本查看 复制代码 HttpItemObj.URL = string.Format("http://passport.feng.com/index.php?r=user/LoginProcess");
HttpItemObj.Method = "POST";
HttpItemObj.Allowautoredirect = true;
HttpItemObj.ContentType = "application/x-www-form-urlencoded; charset=utf-8";
//登录post要用到的参数
//Parameter value
//check_code 验证码,第一次可为空
//password 密码
//username 用户名
//v_token 550c3a9d0b90b 隐藏值,第一步取
//wekey_token 密保动态密码 没用
HttpItemObj.Postdata = string.Format("check_code={0}&password={1}&username={2}&v_token={3}&wekey_token=", string.Empty, this.txtPwd.Text.Trim(), this.txtName.Text.Trim(),strV_token);
HttpItemObj.Header.Add("X-Requested-With", "XMLHttpRequest");
HttpItemObj.Header.Add("Accept-Encoding", "gzip, deflate");
HttpItemObj.Referer = "http://passport.feng.com/?r=user/login&sso%5Bjump%5D=http%3A%2F%2Fbbs.feng.com%2F&sso%5Bname%5D=%E5%A8%81%E9%94%8B%E8%AE%BA%E5%9D%9B&sso%5Bapps%5D=2&sso%5Bverify%5D=7a928982dd59b02a3024858bd61ccf22";
HttpItemObj.Accept = "application/json, text/javascript, */*; q=0.01";
HttpItemObj.UserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)";
HttpItemObj.Encoding = Encoding.UTF8;
HttpItemObj.Cookie = cookies;
HttpResultObj = HttpHelperObj.GetHtml(HttpItemObj);
cookies = HttpResultObj.Cookie;
string strReulst = HttpResultObj.Html; //这里就会返回 json是否成功
//3、访问论坛主页bbs.feng.com .获取其html代码,显示还是未登录的状态[C#] 纯文本查看 复制代码 HttpItemObj.Method = "GET";
HttpItemObj.URL = string.Format("http://bbs.feng.com");
HttpItemObj.Referer = "http://passport.feng.com/?r=user/login&sso%5Bjump%5D=http%3A%2F%2Fbbs.feng.com%2F&sso%5Bname%5D=%E5%A8%81%E9%94%8B%E8%AE%BA%E5%9D%9B&sso%5Bapps%5D=2&sso%5Bverify%5D=7a928982dd59b02a3024858bd61ccf22";
HttpItemObj.Encoding = Encoding.UTF8;
HttpItemObj.Allowautoredirect = true;
HttpItemObj.Accept = "text/html, application/xhtml+xml, */*";
HttpItemObj.ContentType = "application/x-www-form-urlencoded; charset=utf-8";
HttpItemObj.UserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)";
HttpItemObj.Header.Add("X-Requested-With", "XMLHttpRequest");
HttpItemObj.Header.Add("Accept-Encoding", "gzip, deflate");
HttpResultObj.Cookie = cookies;
HttpResultObj = HttpHelperObj.GetHtml(HttpItemObj);
cookies = HttpResultObj.Cookie;
string strHtml = HttpResultObj.Html; //参考页面源码,还是未登录的状态
之后 在步骤3 之前又 加入一个get,这个get的ulr是 json数据后的 url,通过get此url后得到的cookie, 再次赋给 步骤3的cookie用,还是显示未登录
要疯了
希望高手帮帮忙呗,就是登录成功后,能到得到自己的信息就可以了
|