迷你版QQ实现,采用WEBQQ协议,具备登陆,获取qq好友列表,收发消息功能。
只做学习之用,无任何价值,有兴趣的童鞋拿出修改完善。
对于qq号和密码填写正确,但出现这种情况的原因可能是你的qq需要验证码登陆。
获取验证码的方法很简单
直接去
http://captcha.qq.com/getimage?aid=1003903&uin="+qq号码+"&vc_type="+checkType; //代码登陆的时候有这个checkType
发送http请求,将结果写出图片文件,打开图片就可以看到验证码 。
代码中加入手动加入验证码即可正常登陆。 (代码中131行 验证码)
InputStreamReader ins = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(ins); check = br.readLine();
package com.mrlans.qq; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Serializable; import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.ListIterator; import java.util.Map; import java.util.Random; import java.util.Set; import java.util.Map.Entry; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.GZIPInputStream; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import atg.taglib.json.JsonEntity; import atg.taglib.json.util.JSONArray; import atg.taglib.json.util.JSONException; import atg.taglib.json.util.JSONObject; import atg.taglib.json.util.JSONStringer; /** * QQ MINI 客户端 * @author mrlans E-mail:mrlans@qq.com * @version create Time:Dec 11, 2010 8:54:38 PM * */ @SuppressWarnings({"unused","deprecation"}) public class MiniQQClient { private int qq = 4008403; private String password = null; private int clientid = 73937875; private String psessionid = ""; private String ptwebqq; private String vfwebqq; private String skey; private final String host = "http://d.web2.qq.com"; private String refer = this.host+"/proxy.html?v=20101025002"; private String cookie = ""; private Map<Long, User> firends = new HashMap<Long, User>(); private Map<Long, User> firends2 = new HashMap<Long, User>(); public enum METHOD {GET, POST} private boolean run = false; private PollMessageThread poll = new PollMessageThread(); public Thread getPoolThread() { return poll; } public MiniQQClient(int qq, String password) { this.qq = qq; this.password = password; try { boolean login = login(); if(login) { //fetchAllOnlineFriends(); fetchAllFriends(); run = true; getPoolThread().start(); log("QQ START SUCESS......."); sendMsgToQQ(4008403, "哥上线了!"); } } catch (Exception e) { log("QQ发生异常退出\t"+e.getMessage()); Thread.currentThread().stop(); } } public static void main(String[] args) { MiniQQClient clinet = new MiniQQClient(4008403, "密码填写处"); try { clinet.getPoolThread().join(); } catch (Exception e) { System.out.println("QQ异常退出\t"+e.getMessage()); } } private boolean login() { //login 1 String checkQQUrl = "http://ptlogin2.qq.com/check?appid=1003903&uin="+qq; String result = sendHttpMessage(checkQQUrl, METHOD.GET.name(), null); Pattern p = Pattern. compile("\\,\\'([!\\w]+)\\'"); Matcher m = p. matcher(result); String checkType = ""; if(m.find()) { checkType = m.group(1); } String check = ""; if(!checkType.startsWith("!")) { //生成图片验证码 } else { check = checkType; } //login 2 String loginUrl = "http://ptlogin2.qq.com/login?u="+qq+"&" + "p=" +encodePass(this.password, 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"; result = sendHttpMessage(loginUrl, METHOD.GET.name(), null); p = Pattern.compile("登录成功!"); m = p. matcher(result); if(m.find()) { log("Welcome QQ : "+this.qq+" Login Success!"); } else { log(checkType); return false; } //从cookie中提取ptwebqq,skey p = Pattern.compile("ptwebqq=(\\w+);"); m = p.matcher(cookie); if(m.find()) { this.ptwebqq = m.group(1); } p = Pattern.compile("skey=(@\\w+);"); m = p.matcher(cookie); if(m.find()) { this.skey = m.group(1); } //log("ptwebqq="+ptwebqq+",skey="+skey); //login 3 String channelLoginUrl = this.host+"/channel/login2"; String content = "{\"status\":\"\",\"ptwebqq\":\""+ptwebqq+"\",\"passwd_sig\":\"\",\"clientid\":\""+clientid+"\"}"; try { content = URLEncoder.encode(content,"UTF-8"); } catch (UnsupportedEncodingException e) { } content = "r="+content;//post的数据 result = sendHttpMessage(channelLoginUrl, METHOD.POST.name(), content); p = Pattern.compile("\"vfwebqq\":\"(\\w+)\""); m = p.matcher(result); if(m.find()) this.vfwebqq = m.group(1); p = Pattern.compile("\"psessionid\":\"(\\w+)\""); m = p.matcher(result); if(m.find()) psessionid = m.group(1); //log("vwebqq="+vfwebqq); //log("psessionid="+psessionid); return true; } //登陆成功 取QQ好友 public void fetchAllFriends() { String getFriendsurl = "http://web2-b.qq.com/api/get_user_friends2"; String getFriendsurl2 = "http://web2-b.qq.com/api/get_user_friends"; String result = fetchAllFriends(getFriendsurl); String result2 = fetchAllFriends(getFriendsurl2); //firends Map<String, User> user = getFriendInfo(result); // Map<String, User> user2 = getFriendInfo(result2); //真正的QQ号码 if(user!=null && user2!=null && user.size() == user2.size()) { Set<Map.Entry<String, User>> set = user.entrySet(); for(Iterator<Entry<String, User>> it = set.iterator(); it.hasNext();) { Entry<String, User> e = it.next(); User u = e.getValue(); u.setQq(user2.get(e.getKey()).getUin()); log(u.getQq()+"\t"+u.getNick()+"\t"+u.getUin()); firends.put(u.getQq(), u); firends2.put(u.getUin(), u); } } } //在线用户 public void fetchAllOnlineFriends() { String onlineUserURL = host+"/channel/get_online_buddies2"; onlineUserURL = onlineUserURL+ "?clientid="+clientid+"&psessionid="+psessionid; String result = sendHttpMessage(onlineUserURL, METHOD.GET.name(), null); System.out.println(result); } @SuppressWarnings("unchecked") public Map<String, User> getFriendInfo(String result) { Map<String, User> users = new HashMap<String, User>(500); try { JSONObject retJson = new JSONObject(result); if( retJson.getInt("retcode") == 0) { JSONArray infos = retJson.getJSONObject("result").getJSONArray("info"); for(ListIterator<JSONObject> it = infos.listIterator(); it.hasNext();) { JSONObject obj = it.next(); User user = new User(obj.getLong("uin"), obj.getString("nick"), obj.getInt("face"), obj.getLong("flag")); users.put(user.getNick()+user.getFlag(), user); } } } catch (Exception e) { log("getFriendInfo failure "+e.getMessage()); } return users; } public String fetchAllFriends(String getFriendsurl) { //{"h":"hello","vfwebqq":"7fe84931db23dc5a0351d759905642bcf5d09632e001bbfc8822809067538431d4da9dd1e8e653a0"} String content = "{\"h\":\"hello\",\"vfwebqq\":\""+vfwebqq+"\"}"; try { content = URLEncoder.encode(content, "UTF-8"); content = "r="+content; String result = sendHttpMessage(getFriendsurl, METHOD.POST.name(), content); //log("AllFriends= "+result); return result; } catch (Exception e) { log("fetchAllFriends failure.............\t"+e.getMessage()); return null; } } public User getFriend(long qq) { return this.firends.get(qq); } public boolean sendMsg(long toQQ, String message) { try { JSONObject json = new JSONObject(); json.put("to", toQQ);//要发送的人 json.put("face", 330); JSONArray msg = new JSONArray(); msg.add(message); JSONArray font = new JSONArray(); font.add("font"); JSONObject font1 = new JSONObject().put("name", "宋体").put("size", "10"); JSONArray style = new JSONArray(); style.add(0); style.add(0); style.add(0); font1.put("style", style); font1.put("color", "000000"); font.add(font1); msg.add(font); json.put("content", msg.toString()); json.put("msg_id", new Random().nextInt(10000000)); json.put("clientid", this.clientid); json.put("psessionid", this.psessionid);//需要这个才能发送 String sendMsgUrl = this.host+"/channel/send_msg2"; String content = json.toString(); try { content = URLEncoder.encode(content,"UTF-8"); } catch (UnsupportedEncodingException e) { }//他要需要编码 content ="r="+content; //发送 String res = sendHttpMessage(sendMsgUrl, METHOD.POST.name(), content); //不出意外,这是返回结果:{"retcode":0,"result":"ok"} if(null == res || !res.contains("result")) return false; JSONObject rh = new JSONObject(res); if("ok".equals(rh.getString("result"))) { return true; } } catch (Exception e) { log("send message to "+toQQ+" failure......\n"+e.getMessage()); } return false; } public boolean sendMsgToQQ(long qq, String message) { return sendMsg(getFriend(qq).getUin(), message); } //HTTP 消息发送 public String sendHttpMessage(String url, String method, String contents) { try { log("request="+url); URL serverUrl = new URL(url); HttpURLConnection conn = (HttpURLConnection) serverUrl.openConnection(); conn.setConnectTimeout(20000); conn.setRequestMethod(method);//"POST" ,"GET" if(null != refer) conn.addRequestProperty("Referer", refer); conn.addRequestProperty("Cookie", cookie); conn.addRequestProperty("Connection", "Keep-Alive"); conn.addRequestProperty("Accept-Language", "zh-cn"); conn.addRequestProperty("Accept-Encoding", "gzip, deflate"); conn.addRequestProperty("Cache-Control", "no-cache"); conn.addRequestProperty("Accept-Charset", "UTF-8;"); conn.addRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727)"); if(method.equalsIgnoreCase(METHOD.GET.name())) { conn.connect(); } else if(method.equalsIgnoreCase(METHOD.POST.name())) { conn.setDoOutput(true); conn.connect(); conn.getOutputStream().write(contents.getBytes()); } else throw new RuntimeException("your method is not implement"); if(conn.getHeaderFields().get("Set-Cookie") != null) { for(String s:conn.getHeaderFields().get("Set-Cookie")) { cookie += s; } } InputStream ins = conn.getInputStream(); //处理GZIP压缩的 if(null != conn.getHeaderField("Content-Encoding") && conn.getHeaderField("Content-Encoding").equals("gzip")) { byte[] b = null; GZIPInputStream gzip = new GZIPInputStream(ins); byte[] buf = new byte[1024*8]; int num = -1; ByteArrayOutputStream baos = new ByteArrayOutputStream(); while ((num = gzip.read(buf, 0, buf.length)) != -1) { baos.write(buf, 0, num); } b = baos.toByteArray(); baos.flush(); baos.close(); gzip.close(); ins.close(); return new String(b).trim(); } String charset = "UTF-8"; InputStreamReader inr = new InputStreamReader(ins, charset); BufferedReader br = new BufferedReader(inr); String line = ""; StringBuffer sb = new StringBuffer(); do { sb.append(line); line = br.readLine(); }while(line != null); log("response="+sb); return sb.toString(); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } } //加密密码 public String encodePass(String pass, String code) { try { ScriptEngineManager m = new ScriptEngineManager(); ScriptEngine se = m.getEngineByName("javascript"); se.eval(new FileReader(new File(this.getClass().getClassLoader().getResource("com/mrlans/qq/1.js").getPath()))); Object t = se.eval("md5(md5_3(\""+pass+"\")+\""+code.toUpperCase()+"\");"); return t.toString(); }catch (Exception e) { e.printStackTrace(); } return null; } // 记录日志 private void log(String msg) { System.out.println(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date())+" : "+ msg); } public String numToIp(Long num) { String aaa = Long.toHexString(num); String n1 = Integer.parseInt(aaa.substring(0,2),16)+""; String n2 = Integer.parseInt(aaa.substring(2,4),16)+""; String n3 = Integer.parseInt(aaa.substring(4,6),16)+""; String n4 = Integer.parseInt(aaa.substring(6),16)+""; return n1+"."+n2+"."+n3+"."+n4; } public void receiveMsg(JSONObject value) throws Exception { String content = value.getJSONArray("content").getString(1); long from_uin = value.getLong("from_uin"); long reply_ip = value.getLong("reply_ip"); sendMsg(from_uin, "此乃QQ聊天机器人程序测试中,消息会转发到QQ:4008403上"); Thread.sleep(2000); User u = firends2.get(from_uin); if(null == u) sendMsgToQQ(4008403, "[qq = "+from_uin+"] send message :\r\n"+content); else { log("receive [qq = "+u.getQq()+" and name ="+u.getNick()+"] message {"+content+"} ~~~"); sendMsgToQQ(4008403, "[qq = "+u.getQq()+" and name ="+u.getNick()+"] send message :\r\n"+content); } } public void changeStatus(JSONObject value) throws Exception { long from_uin = value.getLong("uin"); String status = value.getString("status"); User u = firends2.get(from_uin); log("用户:"+u.getNick()+"\t"+status); } class PollMessageThread extends Thread { @Override public void run() { String pollUrl = host+ "/channel/poll2?clientid="+clientid+"&psessionid="+psessionid; while(run) { try { String ret= sendHttpMessage(pollUrl, METHOD.GET.name(), null); JSONObject retJ = new JSONObject(ret); int retcode = retJ.getInt("retcode"); if(retcode == 0) { JSONArray result = retJ.getJSONArray("result"); String poll_type = result.getJSONObject(0).getString("poll_type"); JSONObject value = result.getJSONObject(0).getJSONObject("value"); if("message".equals(poll_type)) {//好友消息 try { receiveMsg(value); } catch (Exception e) { } } else if("buddies_status_change".equals(poll_type)) {//好友上下线 changeStatus(value); } else if("group_message".equals(poll_type)) {//群消息 } //system_message 是系统消息 } else if(retcode == 121) { run = false; log("QQ已经在别处登录!"); } } catch (Exception e) { // TODO: handle exception log("Response PollMessage failure = "+e.getMessage()); } } } } } @SuppressWarnings("serial") class User implements Serializable { private long uin; private long qq; private String nick; private int face; private long flag; public User() { super(); } public User(long uin, String nick, int face, long flag) { super(); this.uin = uin; this.nick = nick; this.face = face; this.flag = flag; } public long getUin() { return uin; } public void setUin(long uin) { this.uin = uin; } public long getQq() { return qq; } public void setQq(long qq) { this.qq = qq; } public String getNick() { return nick; } public void setNick(String nick) { this.nick = nick; } public int getFace() { return face; } public void setFace(int face) { this.face = face; } public long getFlag() { return flag; } public void setFlag(long flag) { this.flag = flag; } @Override public String toString() { String user = this.uin+"\t\t"+this.qq+"\t\t"+this.nick+"\t\t"+this.flag; return user; } }
35 楼
kktxah
2011-06-17
2011-06-17 01:12:27 : request=http://ptlogin2.qq.com/check?appid=1003903&uin=409588068
2011-06-17 01:12:27 : response=ptui_checkVC('1','fe600177f8f866141e89fb3bd4ad907c283bf8ac6959e7c6');
2011-06-17 01:12:27 : request=http://ptlogin2.qq.com/login?u=409588068&p=B30687A8EDDCD6C1495A454B56E7306A&verifycode=&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
2011-06-17 01:12:27 : response=ptuiCB('7','0','','0','您的输入有误, 请重试。');
2011-06-17 01:12:27 : fe600177f8f866141e89fb3bd4ad907c283bf8ac6959e7c6
神马情况
2011-06-17 01:12:27 : response=ptui_checkVC('1','fe600177f8f866141e89fb3bd4ad907c283bf8ac6959e7c6');
2011-06-17 01:12:27 : request=http://ptlogin2.qq.com/login?u=409588068&p=B30687A8EDDCD6C1495A454B56E7306A&verifycode=&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
2011-06-17 01:12:27 : response=ptuiCB('7','0','','0','您的输入有误, 请重试。');
2011-06-17 01:12:27 : fe600177f8f866141e89fb3bd4ad907c283bf8ac6959e7c6
神马情况
36 楼
wangyu1221
2011-06-17
kktxah 写道
2011-06-17 01:12:27 : request=http://ptlogin2.qq.com/check?appid=1003903&uin=409588068
2011-06-17 01:12:27 : response=ptui_checkVC('1','fe600177f8f866141e89fb3bd4ad907c283bf8ac6959e7c6');
2011-06-17 01:12:27 : request=http://ptlogin2.qq.com/login?u=409588068&p=B30687A8EDDCD6C1495A454B56E7306A&verifycode=&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
2011-06-17 01:12:27 : response=ptuiCB('7','0','','0','您的输入有误, 请重试。');
2011-06-17 01:12:27 : fe600177f8f866141e89fb3bd4ad907c283bf8ac6959e7c6
神马情况
2011-06-17 01:12:27 : response=ptui_checkVC('1','fe600177f8f866141e89fb3bd4ad907c283bf8ac6959e7c6');
2011-06-17 01:12:27 : request=http://ptlogin2.qq.com/login?u=409588068&p=B30687A8EDDCD6C1495A454B56E7306A&verifycode=&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
2011-06-17 01:12:27 : response=ptuiCB('7','0','','0','您的输入有误, 请重试。');
2011-06-17 01:12:27 : fe600177f8f866141e89fb3bd4ad907c283bf8ac6959e7c6
神马情况
main里填了密码没?
37 楼
kktxah
2011-06-17
wangyu1221 写道
kktxah 写道
2011-06-17 01:12:27 : request=http://ptlogin2.qq.com/check?appid=1003903&uin=409588068
2011-06-17 01:12:27 : response=ptui_checkVC('1','fe600177f8f866141e89fb3bd4ad907c283bf8ac6959e7c6');
2011-06-17 01:12:27 : request=http://ptlogin2.qq.com/login?u=409588068&p=B30687A8EDDCD6C1495A454B56E7306A&verifycode=&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
2011-06-17 01:12:27 : response=ptuiCB('7','0','','0','您的输入有误, 请重试。');
2011-06-17 01:12:27 : fe600177f8f866141e89fb3bd4ad907c283bf8ac6959e7c6
神马情况
2011-06-17 01:12:27 : response=ptui_checkVC('1','fe600177f8f866141e89fb3bd4ad907c283bf8ac6959e7c6');
2011-06-17 01:12:27 : request=http://ptlogin2.qq.com/login?u=409588068&p=B30687A8EDDCD6C1495A454B56E7306A&verifycode=&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
2011-06-17 01:12:27 : response=ptuiCB('7','0','','0','您的输入有误, 请重试。');
2011-06-17 01:12:27 : fe600177f8f866141e89fb3bd4ad907c283bf8ac6959e7c6
神马情况
main里填了密码没?
填了密码的啊 为什么显示 输入有误啊
38 楼
kktxah
2011-06-17
终于调试出来啦,可以用 好东西啊
39 楼
mrlans
2011-06-17
kktxah 写道
wangyu1221 写道
kktxah 写道
2011-06-17 01:12:27 : request=http://ptlogin2.qq.com/check?appid=1003903&uin=409588068
2011-06-17 01:12:27 : response=ptui_checkVC('1','fe600177f8f866141e89fb3bd4ad907c283bf8ac6959e7c6');
2011-06-17 01:12:27 : request=http://ptlogin2.qq.com/login?u=409588068&p=B30687A8EDDCD6C1495A454B56E7306A&verifycode=&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
2011-06-17 01:12:27 : response=ptuiCB('7','0','','0','您的输入有误, 请重试。');
2011-06-17 01:12:27 : fe600177f8f866141e89fb3bd4ad907c283bf8ac6959e7c6
神马情况
2011-06-17 01:12:27 : response=ptui_checkVC('1','fe600177f8f866141e89fb3bd4ad907c283bf8ac6959e7c6');
2011-06-17 01:12:27 : request=http://ptlogin2.qq.com/login?u=409588068&p=B30687A8EDDCD6C1495A454B56E7306A&verifycode=&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
2011-06-17 01:12:27 : response=ptuiCB('7','0','','0','您的输入有误, 请重试。');
2011-06-17 01:12:27 : fe600177f8f866141e89fb3bd4ad907c283bf8ac6959e7c6
神马情况
main里填了密码没?
填了密码的啊 为什么显示 输入有误啊
对于qq号和密码填写正确,但出现这种情况的原因可能是你的qq需要验证码登陆,
获取验证码的方法很简单
直接去
http://captcha.qq.com/getimage?aid=1003903&uin="+qq号码+"&vc_type="+checkType; //代码登陆的时候有这个checkType
发送http请求,将结果写出图片文件,打开图片就可以看到验证码
代码中加入手动加入验证码即可正常登陆。
InputStreamReader ins = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(ins); check = br.readLine();
40 楼
mrlans
2011-06-17
wangyu1221 写道
两次获取好友原来是分别取uin和qq号码
是这样的,没办法,马哥喜欢折腾人。
41 楼
wangyu1221
2011-06-17
mrlans 写道
wangyu1221 写道
两次获取好友原来是分别取uin和qq号码
是这样的,没办法,马哥喜欢折腾人。
好像没办法把uin和qq建立关联啊,所以用了两个map存放对吗?
42 楼
openFox
2011-06-17
shybo 写道
nrxqq 写道
楼主是怎么知道webqq通信协议的
走的是http协议,没看嘛,自己包装的http数据包,包装好后,模拟浏览器发送的数据包,实际上是java程序直接从网卡发送的数据,跳过了走浏览器这一步
+1
43 楼
zhao_chong
2011-06-17
请问怎么发送信息?
44 楼
zyengogo
2011-06-17
怎么聊天勒!~莫非聊天!~
45 楼
wangyu1221
2011-06-17
zhao_chong 写道
请问怎么发送信息?
public boolean sendMsgToQQ(long qq, String message)
46 楼
wangyu1221
2011-06-17
获取好友详细信息,这里没有QQ号码。
User的属性参照修改~
User的属性参照修改~
public User getFriendInfo2(User user) { String onlineUserURL = "http://s.web2.qq.com/api/get_friend_info2?tuin=" + user.getUin() + "&verifysession=&code=&vfwebqq=" + this.vfwebqq; String result = sendHttpMessage(onlineUserURL, METHOD.GET.name(), null); try { JSONObject retJson = new JSONObject(result); JSONObject obj = retJson.getJSONObject("result"); if(obj.isNull("stat")){ user.setStat(-1); }else{ user.setStat(obj.getInt("stat")); } if(obj.isNull("vip_info")){ user.setVipInfo(-1); }else{ user.setVipInfo(obj.getInt("vip_info")); } user.setCountry(obj.getString("country")); user.setProvince(obj.getString("province")); user.setCity(obj.getString("city")); user.setGender(obj.getString("gender")); JSONObject birthday = obj.getJSONObject("birthday"); user.setBirthday(birthday.getString("year") + "-" + birthday.getString("month") + "-" + birthday.getString("day")); user.setBlood(obj.getInt("blood")); user.setShengxiao(obj.getInt("shengxiao")); user.setConstel(obj.getInt("constel")); user.setPhone(obj.getString("phone")); user.setMobile(obj.getString("mobile")); user.setEmail(obj.getString("email")); user.setOccupation(obj.getString("occupation")); user.setCollege(obj.getString("college")); user.setHomepage(obj.getString("homepage")); user.setPersonal(obj.getString("personal")); user.setAllow(obj.getInt("allow")); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return user; }
47 楼
lzj0470
2011-06-17
2011-06-17 10:26:01 : request=http://ptlogin2.qq.com/check?appid=1003903&uin=1574342736
2011-06-17 10:26:02 : response=ptui_checkVC('1','317d8180b186272561bf358ba1be5b96178db8be5bad747a');
result=ptui_checkVC('1','317d8180b186272561bf358ba1be5b96178db8be5bad747a');
么么~~需要验证码噢
ZNTX
2011-06-17 10:26:17 : request=http://ptlogin2.qq.com/login?u=1574342736&p=239109E6D9859A7CF473C8A7BAC02859&verifycode=ZNTX&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
2011-06-17 10:26:18 : response=ptuiCB('50','0','','0','参数非法(3069184902)');
2011-06-17 10:26:18 : 317d8180b186272561bf358ba1be5b96178db8be5bad747a
这个错误怎么解决~~
2011-06-17 10:26:02 : response=ptui_checkVC('1','317d8180b186272561bf358ba1be5b96178db8be5bad747a');
result=ptui_checkVC('1','317d8180b186272561bf358ba1be5b96178db8be5bad747a');
么么~~需要验证码噢
ZNTX
2011-06-17 10:26:17 : request=http://ptlogin2.qq.com/login?u=1574342736&p=239109E6D9859A7CF473C8A7BAC02859&verifycode=ZNTX&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
2011-06-17 10:26:18 : response=ptuiCB('50','0','','0','参数非法(3069184902)');
2011-06-17 10:26:18 : 317d8180b186272561bf358ba1be5b96178db8be5bad747a
这个错误怎么解决~~
48 楼
127.0.0.1
2011-06-18
想不到这几页的帖子就已经泄露了两个QQ号及对应的密码了:
409588068: B30687A8EDDCD6C1495A454B56E7306A
1574342736: 239109E6D9859A7CF473C8A7BAC02859
...
409588068: B30687A8EDDCD6C1495A454B56E7306A
1574342736: 239109E6D9859A7CF473C8A7BAC02859
...
49 楼
qqliuyuxi
2011-06-18
105行MiniQQClient clinet = new MiniQQClient(842984416,"xxxxxxxx");我填了QQ号和密码,还是显示出错,
java.lang.NullPointerException at com.game.qq.MiniQQClient.encodePass(MiniQQClient.java:449)
at com.game.qq.MiniQQClient.login(MiniQQClient.java:140)
at com.game.qq.MiniQQClient.<init>(MiniQQClient.java:84)
at com.game.qq.MiniQQClient.main(MiniQQClient.java:105)
java.lang.NullPointerException at com.game.qq.MiniQQClient.encodePass(MiniQQClient.java:449)
at com.game.qq.MiniQQClient.login(MiniQQClient.java:140)
at com.game.qq.MiniQQClient.<init>(MiniQQClient.java:84)
at com.game.qq.MiniQQClient.main(MiniQQClient.java:105)
50 楼
you
2011-06-18
能访问空间么?
51 楼
it2008chen
2011-06-18
为什么我的QQ好友加载完毕 到这儿就打住了
2011-06-18 10:57:13 : QQ START SUCESS.......
2011-06-18 10:57:13 : QQ发生异常退出 null
2011-06-18 10:57:13 : request=http://d.web2.qq.com/channel/poll2?clientid=73937875&psessionid=8368046764001e636f6e6e7365727665725f7765627171403137322e32372e3138312e383500006fd5000003b5016e04000e7835386d0000000a40734667595a4e6971326d00000028efa3b3274283aee21c4ad942ed1ac85f9e3b735498855d29431c6abd058f9413d59dad97c025e5a7
2011-06-18 10:57:13 : QQ START SUCESS.......
2011-06-18 10:57:13 : QQ发生异常退出 null
2011-06-18 10:57:13 : request=http://d.web2.qq.com/channel/poll2?clientid=73937875&psessionid=8368046764001e636f6e6e7365727665725f7765627171403137322e32372e3138312e383500006fd5000003b5016e04000e7835386d0000000a40734667595a4e6971326d00000028efa3b3274283aee21c4ad942ed1ac85f9e3b735498855d29431c6abd058f9413d59dad97c025e5a7
52 楼
wangyu1221
2011-06-18
获取群列表
@SuppressWarnings("unchecked") public Map<Long, Group> fetchAllGroups() { Map<Long, Group> groups = new HashMap<Long, Group>(); String getGroupsurl = "http://web2-b.qq.com/api/get_group_name_list_mask2"; String content = "{\"vfwebqq\":\"" + vfwebqq + "\"}"; try { content = URLEncoder.encode(content, "UTF-8"); content = "r=" + content; String result = sendHttpMessage(getGroupsurl, METHOD.POST.name(), content); JSONObject retJson = new JSONObject(result); //System.out.println(result); if (retJson.getInt("retcode") == 0) { Iterator it = retJson.getJSONObject("result").getJSONArray("gnamelist").listIterator(); while(it.hasNext()){ JSONObject obj = (JSONObject)it.next(); Group group = new Group(); group.setGid(obj.getLong("gid")); group.setCode(obj.getLong("code")); group.setFlag(obj.getLong("flag")); group.setName(obj.getString("name")); groups.put(group.getGid(), group); } } } catch (Exception e) { log("fetchAllGroups failure.............\t" + e.getMessage()); } return groups; }
53 楼
yunnysunny
2011-06-18
shybo 写道
nrxqq 写道
楼主是怎么知道webqq通信协议的
走的是http协议,没看嘛,自己包装的http数据包,包装好后,模拟浏览器发送的数据包,实际上是java程序直接从网卡发送的数据,跳过了走浏览器这一步
难道是通过抓包来换取的通信过程?
54 楼
fxj
2011-11-05
能改成php实现么?