private boolean checkAndLogin() throws Exception{
		if(qq == -1 || pwd == null)
			throw new IllegalArgumentException("qq和密码不能为空");
		String checkIdUrl = "http://ptlogin2.qq.com/check?appid=1003903&uin="+qq;
		String res = getUrl(checkIdUrl);
		//ptui_checkVC('0','!ZLE');返回这个就不需要获取验证码了。验证码就是!ZLE 
		//ptui_checkVC('1','95ab7db15e5ab17f50f25d33598259e83ccc098c4af2f8a4');这个长字符串就需要使用了
		Pattern p = Pattern. compile("\\,\\'([!\\w]+)\\'");
		Matcher m = p. matcher(res);
		String checkType = "";
		if(m.find()){
			checkType = m.group(1); 
		}
		String check = ""; 
		if(!checkType.startsWith("!")){
			//需要输入验证码
			String getCheckImageUrl = "http://captcha.qq.com/getimage?aid=1003903&uin="+qq+"&vc_type="+checkType;
			String file = readCheckImage(getCheckImageUrl);
			log("请打开"+file+"，并且在这里输入其中的字符串，然后回车：");
			InputStreamReader ins = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(ins);
			check = br.readLine();	
		}else{
			//不需要输入验证码
			check = checkType;
		}
		
		//开始登陆
		String loginUrl = "http://ptlogin2.qq.com/login?u="+qq+"&" +
				"p=" +mdP(pwd, check)+
				"&verifycode="+check+"&remember_uin=1&aid=1003903" +
				"&u1=http%3A%2F%2Fweb2.qq.com%2Floginproxy.html%3Fstrong%3Dtrue" +
				"&h=1&ptredirect=0&ptlang=2052&from_ui=1&pttype=1&dumy=&fp=loginerroralert";
		res = getUrl(loginUrl);
//		ptuiCB('0','0','http://web2.qq.com/loginproxy.html?strong=true','0','登录成功！');
//		ptuiCB('4','0','','0','您输入的验证码有误，请重试。');
	 
		p = Pattern.compile("登录成功！");//提取最后一个字符串，看看是不是 登录成功！
		m = p. matcher(res);
		if(m.find()){
			log("登陆成功"); 
		}else{
			//登陆失败
			log(checkType);
			return false;
		}
		//从cookie中提取ptwebqq,skey
		p = Pattern.compile("ptwebqq=(\\w+);");
		m = p.matcher(cookie);
		if(m.find()){
			ptwebqq = m.group(1);
		}
		p = Pattern.compile("skey=(@\\w+);");
		m = p.matcher(cookie);
		if(m.find()){
			skey = m.group(1);
		}
		log("ptwebqq="+ptwebqq+",skey="+skey);
		
		//再次登陆，只有这次登陆，才算真正登陆qq，这个时候，如果你qq已经登陆，会把你的qq踢下线，而且此次登陆才算上线。
		String channelLoginUrl = "http://web2-b.qq.com/channel/login";
		String content = "{\"status\":\"\",\"ptwebqq\":\""+ptwebqq+"\",\"passwd_sig\":\"\",\"clientid\":\""+clientid+"\"}";
		content = URLEncoder.encode(content);//urlencode 
		content = "r="+content;//post的数据
		res = postUrl(channelLoginUrl, content);//post
		//这次登陆基本上不会发生什么问题
		//下面提取很重要的2个数据psessionid ,vwebqq，通用采用正则表达式,虽然结果是个json
		p = Pattern.compile("\"vfwebqq\":\"(\\w+)\"");
		m = p.matcher(res);
		if(m.find()){
			vfwebqq = m.group(1);
		}
		p = Pattern.compile("\"psessionid\":\"(\\w+)\"");
		m = p.matcher(res);
		if(m.find()){
			psessionid = m.group(1);
		}
		log("vwebqq="+vfwebqq+","+"psessionid="+psessionid);
		//到此，登陆就算完成了，后面可以调用发送qq信息等接口了		
		 return true;
	}