/** {@inheritDoc} */ public void execute() { try { switch (type) { case Type.BUILD_REQUEST: { ApacheHttpService service = context.getSerivce(); QQHttpRequest request = action.onBuildRequest(); service.executeHttpRequest(request, new HttpAdaptor(context, action)); } break; case Type.ON_HTTP_ERROR: action.onHttpError(throwable); break; case Type.ON_HTTP_FINISH: action.onHttpFinish(response); break; } } catch (QQException e) { action.notifyActionEvent(QQActionEvent.Type.EVT_ERROR, e); } }
/** {@inheritDoc} */ public override QQHttpRequest onBuildRequest() { ApacheHttpService httpService = getContext().getSerivce(); QQSession session = getContext().getSession(); Random rand = new Random(); if (session.getClientId() == 0) { session.setClientId(rand.Next()); //random?? } JSONObject json = new JSONObject(); json.put("status", "online"); json.put("ptwebqq", httpService.getCookie("ptwebqq", QQConstants.URL_CHANNEL_LOGIN).Value); json.put("passwd_sig", ""); json.put("clientid", session.getClientId()); json.put("psessionid", session.getSessionId()); QQHttpRequest req = createHttpRequest("POST", QQConstants.URL_CHANNEL_LOGIN); req.addPostValue("r", json.ToString()); req.addPostValue("clientid", session.getClientId() + ""); req.addPostValue("psessionid", session.getSessionId()); //req.addHeader("Referer", QQConstants.REFFER); return(req); }
/** * 构造方法,初始化模块和服务 * 账号/密码 监听器 线程执行器 * * @param username a {@link java.lang.String} object. * @param password a {@link java.lang.String} object. * @param notifyListener a {@link iqq.im.QQNotifyListener} object. * @param actorDispatcher a {@link iqq.im.actor.ThreadActorDispatcher} object. */ public WebQQClient( QQNotifyListener notifyListener, ThreadActorDispatcher actorDispatcher) { this.modules = new Dictionary <AbstractModule.Type, AbstractModule>(); this.modules.Add(AbstractModule.Type.LOGIN, new LoginModule()); this.modules.Add(AbstractModule.Type.PROC, new ProcModule()); this.modules.Add(AbstractModule.Type.USER, new UserModule()); this.modules.Add(AbstractModule.Type.BUDDY, new BuddyModule()); this.modules.Add(AbstractModule.Type.CATEGORY, new CategoryModule()); this.modules.Add(AbstractModule.Type.GROUP, new GroupModule()); this.modules.Add(AbstractModule.Type.CHAT, new ChatModule()); //this.modules.Add(AbstractModule.Type.DISCUZ, new DiscuzModule()); //this.modules.Add(AbstractModule.Type.EMAIL, new EmailModule()); //this.modules.Add(AbstractModule.Type.QM_LOGIN, new QmLoginModule()); //this.modules.Add(AbstractModule.Type.QM_PROC, new QmProcModule()); //this.modules.Add(AbstractModule.Type.QM_MGR, new QmMgrModule()); //this.modules.Add(AbstractModule.Type.WB_LOGIN, new WbLoginModule()); //this.modules.Add(AbstractModule.Type.WB_PROC, new WbProcModule()); this.service = new ApacheHttpService(); this.session = new QQSession(); this.store = new QQStore(); this.notifyListener = notifyListener; this.actorDispatcher = actorDispatcher; this.init(); }
/** {@inheritDoc} */ public override QQHttpRequest onBuildRequest() { //尝试登录,准备传递的参数值 QQHttpRequest req = createHttpRequest("GET", QQConstants.URL_UI_LOGIN); req.addGetValue("u", username); req.addGetValue("p", QQEncryptor.encryptQm(uin, password, verifyCode)); req.addGetValue("verifycode", verifyCode); req.addGetValue("webqq_type", "10"); req.addGetValue("remember_uin", "1"); req.addGetValue("login2qq", "1"); req.addGetValue("aid", "1003903"); req.addGetValue("u1", "http://web.qq.com/loginproxy.html?login2qq=1&webqq_type=10"); req.addGetValue("h", "1"); req.addGetValue("ptredirect", "0"); req.addGetValue("ptlang", "2052"); req.addGetValue("daid", "164"); req.addGetValue("from_ui", "1"); req.addGetValue("pttype", "1"); req.addGetValue("dumy", ""); req.addGetValue("fp", "loginerroralert"); req.addGetValue("action", "2-12-26161"); req.addGetValue("mibao_css", "m_webqq"); req.addGetValue("t", "1"); req.addGetValue("g", "1"); req.addGetValue("js_type", "0"); req.addGetValue("js_ver", QQConstants.JSVER); req.addGetValue("login_sig", getContext().getSession().getLoginSig()); //2015-03-02 登录协议增加的参数 req.addGetValue("pt_uistyle", "5"); req.addGetValue("pt_randsalt", "0"); req.addGetValue("pt_vcode_v1", "0"); ApacheHttpService httpService = getContext().getSerivce(); Cookie ptvfsession = httpService.getCookie("ptvfsession", QQConstants.URL_UI_LOGIN); if (ptvfsession == null)//验证session在获取验证码阶段得到的。 { ptvfsession = httpService.getCookie("verifysession", QQConstants.URL_UI_LOGIN); } if (ptvfsession != null) { req.addGetValue("pt_verifysession_v1", ptvfsession.Value); } req.addHeader("Referer", QQConstants.REFFER); return(req); }
/** {@inheritDoc} */ public override QQHttpRequest onBuildRequest() { QQSession session = getContext().getSession(); QQAccount account = (QQAccount)getContext().getAccount(); ApacheHttpService httpService = getContext().getSerivce(); Cookie ptwebqq = httpService.getCookie("ptwebqq", QQConstants.URL_GET_USER_CATEGORIES); JSONObject json = new JSONObject(); json.put("h", "hello"); json.put("vfwebqq", session.getVfwebqq()); // 同上 json.put("hash", QQEncryptor.getHash(account.getUin() + "", ptwebqq.Value)); QQHttpRequest req = createHttpRequest("POST", QQConstants.URL_GET_USER_CATEGORIES); req.addPostValue("r", json.ToString()); req.addHeader("Referer", QQConstants.REFFER); return req; }