想用java做个程序来自动登录qq,请大家指点! 客户端的估计不好实现,webqq还可以用httpclient模拟登陆,不过我没试过,应该可以的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 客户端貌似腾讯没开发接口吧,它会说你写外挂!web qq就不清楚了,很少用! 这个是让网站上支持用qq登录的吧?我要的是想让程序帮我把一些qq登录下,发送点消息什么的 对httpclient不熟悉,我先看看吧。哪位大侠出手帮我整个,呵呵 正如2楼所说的,你可以多去了解下 web qq方向, 模拟登录。可以参考:http://www.iteye.com/topic/1092827 客户端的话,用java模拟鼠标和键盘事件或许能行。但这样的话 不如直接弄按键精灵 我找到一篇是登录qq空间的,http://blog.sina.com.cn/s/blog_533587770101iz4f.html,试了一下,貌似是可以登录的,不过验证码部分是需要自己手动打开图片看了再输入的,有点麻烦,我想改成gui界面的,直接显示出图片,然后在JTextField里面输入。 额,QQ是im的,httpClient是http,协议不对吧 ? 客户端估计难度很大。登陆的话,直接按键精灵record吧。发送消息不太好弄。webqq,不知道httpclient能否搞定,没尝试过。 //3.获取登录验证信息 //http://check.ptlogin2.qq.com/check?regmaster=&uin=949102845&appid=549000912&js_ver=10051&js_type=1&login_sig=UcU**IJ7*Tb1oqFs9-NzQ7p187P4QhmPafwtJz5JE4zMXU1mnab0L5Z6uhEeSR4d&u1=http%3A%2F%2Fqzs.qq.com%2Fqzone%2Fv5%2Floginsucc.html%3Fpara%3Dizone&r=0.6652378559988166 String $url = "http://check.ptlogin2.qq.com/check?regmaster=&uin={0}&appid={1}&js_ver={2}&js_type=1&login_sig={3}&u1=http%3A%2F%2Fqzs.qq.com%2Fqzone%2Fv5%2Floginsucc.html%3Fpara%3Dizone&r={4}"; $url = Util.fillString($url, $uin, $aid,"10051",$login_sig,new Random().nextDouble()+""); $v = this.requestGet($url); String $status = RegexUtil.replaceStartEnd($v, "'", "'"); String $verify = RegexUtil.replaceStartEnd($v, ",'", "'"); String $hexqq = RegexUtil.replaceStartEnd($v, ",'\\\\x", "'"); //如果有验证码,一定要在密码加密前搞定哟 if($verify.length()>5){ System.out.println("请进入"+Util.root+"\\verifyTemp\\verify.jpg"+"查看验证码,且在控制台输入验证码→回车"); $url = "http://captcha.qq.com/getimage?uin={0}&aid={1}&{2}"; $url = Util.fillString($url, $uin, $aid, new Random().nextDouble()+""); this.requestDownload($url, Util.root+"\\verifyTemp\\verify.jpg"); //不解释,控制台输入验证码,突然感觉自己好水话又说回来,如果使用B/S架构,这里还要重构。。额,好吧 Scanner scanner = new Scanner(System.in); $verify = scanner.nextLine(); } //获取加密后的密码 $password = Security.GetPassword($hexqq,$password,$verify);原来作者实现的是自己要手动打开验证码图片,然后在控制台手动输入,我想改成gui界面,现在的代码是这样的:JFrame frame = new JFrame("自动登录qq"); frame.setResizable(false); frame.setSize(new Dimension(400, 500)); frame.setLayout(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocation(300, 200); frame.setVisible(true); final JButton postBut = new JButton("确认"); final JLabel lab = new JLabel(); final JTextField image = new JTextField(); final JTextArea resultText = new JTextArea("程序运行结果如下:\n"); final JScrollPane resultPane = new JScrollPane(resultText,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); frame.getContentPane().add(lab, null); frame.getContentPane().add(image, null); frame.getContentPane().add(postBut, null); frame.getContentPane().add(resultPane, null); lab.setBounds(40, 10, 300, 200); image.setBounds(40, 220, 150, 30); postBut.setBounds(200, 220, 100, 30); resultPane.setBounds(10, 270, 380, 200); //3.获取登录验证信息 //http://check.ptlogin2.qq.com/check?regmaster=&uin=949102845&appid=549000912&js_ver=10051&js_type=1&login_sig=UcU**IJ7*Tb1oqFs9-NzQ7p187P4QhmPafwtJz5JE4zMXU1mnab0L5Z6uhEeSR4d&u1=http%3A%2F%2Fqzs.qq.com%2Fqzone%2Fv5%2Floginsucc.html%3Fpara%3Dizone&r=0.6652378559988166 String $url = "http://check.ptlogin2.qq.com/check?regmaster=&uin={0}&appid={1}&js_ver={2}&js_type=1&login_sig={3}&u1=http%3A%2F%2Fqzs.qq.com%2Fqzone%2Fv5%2Floginsucc.html%3Fpara%3Dizone&r={4}"; $url = Util.fillString($url, $uin, $aid,"10051",$login_sig,new Random().nextDouble()+""); $v = this.requestGet($url); String $status = RegexUtil.replaceStartEnd($v, "'", "'"); String $verify = RegexUtil.replaceStartEnd($v, ",'", "'"); String $hexqq = RegexUtil.replaceStartEnd($v, ",'\\\\x", "'"); //如果有验证码,一定要在密码加密前搞定哟 if($verify.length()>5){ System.out.println("请进入"+Util.root+"\\verifyTemp\\verify.jpg"+"查看验证码,且在控制台输入验证码→回车"); $url = "http://captcha.qq.com/getimage?uin={0}&aid={1}&{2}"; $url = Util.fillString($url, $uin, $aid, new Random().nextDouble()+""); this.requestDownload($url, Util.root+"\\verifyTemp\\verify.jpg"); //不解释,控制台输入验证码,突然感觉自己好水话又说回来,如果使用B/S架构,这里还要重构。。额,好吧 File inputFile = new File(Util.root+"\\verifyTemp\\verify.jpg"); FileInputStream os = null; try { os = new FileInputStream(inputFile); } catch (FileNotFoundException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } try { lab.setIcon(new ImageIcon(ImageIO.read(os))); } catch (IOException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } postBut.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent arg0){ if(arg0.getSource()==postBut){// $verify = image.getText(); } } }); Scanner scanner = new Scanner(System.in); $verify = scanner.nextLine(); } //获取加密后的密码 $password = Security.GetPassword($hexqq,$password,$verify);现在是gui界面能显示图片,我如果还在控制台那里输入,是可以的,但是我希望在JTextField这里输入,然后点按钮继续执行,可是// $verify = image.getText(); 这句代码有问题,提示不能引用非终态变量,我把变量加了final也不行,还提示:不能对终态局部变量verify赋值,原因是它是在外层类型中定义的。不知道该怎么解决这个问题了,请高手们指点。 只能看到部分代码。获取验证码部分要与登录的后半部分拆开。 //验证码 String imagePath = Util.root+"\\verifyTemp\\verify.jpg"; ImageIcon image = new ImageIcon(imagePath); //换成图片路径试下。 verificationImage = new JLabel(image); verificationImage.setBounds(150, 100, 80, 30); frame.getContentPane().add(verificationImage); frame.getContentPane()..repaint(); 高人那,开发QQ、自动登陆哭小心被XX告。 多谢兄弟的指点,真是麻烦你了,都不好意思了。大家去看http://blog.sina.com.cn/s/blog_533587770101iz4f.html吧,我已经测试过了,可以实现的。 双核双线程(创建了互斥对象) 为什么有时一个线程执行两遍? synchronized关键字不能被继承的问题 Swing,如何关闭单个窗口,而不是退出整个程序? bangmang 用户登陆 新手問題,求幫忙 未入门新手,一开始就遇到问题,求助! 关于字符串转换成double类型后计算的问题! 怎样在树形节点上加上setToolTipText()? 未装Jbuilder6前Tomcat运行正常,装后就不正常了. src里自己定义的类,与导入lib包的类名、包名,程序运行时使用哪一个 JasperReport Column Chart的item label如何设置为垂直显示?
额,QQ是im的,httpClient是http,协议不对吧 ?
//3.获取登录验证信息
//http://check.ptlogin2.qq.com/check?regmaster=&uin=949102845&appid=549000912&js_ver=10051&js_type=1&login_sig=UcU**IJ7*Tb1oqFs9-NzQ7p187P4QhmPafwtJz5JE4zMXU1mnab0L5Z6uhEeSR4d&u1=http%3A%2F%2Fqzs.qq.com%2Fqzone%2Fv5%2Floginsucc.html%3Fpara%3Dizone&r=0.6652378559988166
String $url = "http://check.ptlogin2.qq.com/check?regmaster=&uin={0}&appid={1}&js_ver={2}&js_type=1&login_sig={3}&u1=http%3A%2F%2Fqzs.qq.com%2Fqzone%2Fv5%2Floginsucc.html%3Fpara%3Dizone&r={4}";
$url = Util.fillString($url, $uin, $aid,"10051",$login_sig,new Random().nextDouble()+""); $v = this.requestGet($url);
String $status = RegexUtil.replaceStartEnd($v, "'", "'");
String $verify = RegexUtil.replaceStartEnd($v, ",'", "'");
String $hexqq = RegexUtil.replaceStartEnd($v, ",'\\\\x", "'");
//如果有验证码,一定要在密码加密前搞定哟
if($verify.length()>5){
System.out.println("请进入"+Util.root+"\\verifyTemp\\verify.jpg"+"查看验证码,且在控制台输入验证码→回车");
$url = "http://captcha.qq.com/getimage?uin={0}&aid={1}&{2}";
$url = Util.fillString($url, $uin, $aid, new Random().nextDouble()+"");
this.requestDownload($url, Util.root+"\\verifyTemp\\verify.jpg");
//不解释,控制台输入验证码,突然感觉自己好水话又说回来,如果使用B/S架构,这里还要重构。。额,好吧
Scanner scanner = new Scanner(System.in);
$verify = scanner.nextLine();
}
//获取加密后的密码
$password = Security.GetPassword($hexqq,$password,$verify);原来作者实现的是自己要手动打开验证码图片,然后在控制台手动输入,我想改成gui界面,现在的代码是这样的:JFrame frame = new JFrame("自动登录qq");
frame.setResizable(false);
frame.setSize(new Dimension(400, 500));
frame.setLayout(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocation(300, 200);
frame.setVisible(true);
final JButton postBut = new JButton("确认");
final JLabel lab = new JLabel();
final JTextField image = new JTextField();
final JTextArea resultText = new JTextArea("程序运行结果如下:\n");
final JScrollPane resultPane = new JScrollPane(resultText,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
frame.getContentPane().add(lab, null);
frame.getContentPane().add(image, null);
frame.getContentPane().add(postBut, null);
frame.getContentPane().add(resultPane, null);
lab.setBounds(40, 10, 300, 200);
image.setBounds(40, 220, 150, 30);
postBut.setBounds(200, 220, 100, 30);
resultPane.setBounds(10, 270, 380, 200); //3.获取登录验证信息
//http://check.ptlogin2.qq.com/check?regmaster=&uin=949102845&appid=549000912&js_ver=10051&js_type=1&login_sig=UcU**IJ7*Tb1oqFs9-NzQ7p187P4QhmPafwtJz5JE4zMXU1mnab0L5Z6uhEeSR4d&u1=http%3A%2F%2Fqzs.qq.com%2Fqzone%2Fv5%2Floginsucc.html%3Fpara%3Dizone&r=0.6652378559988166
String $url = "http://check.ptlogin2.qq.com/check?regmaster=&uin={0}&appid={1}&js_ver={2}&js_type=1&login_sig={3}&u1=http%3A%2F%2Fqzs.qq.com%2Fqzone%2Fv5%2Floginsucc.html%3Fpara%3Dizone&r={4}";
$url = Util.fillString($url, $uin, $aid,"10051",$login_sig,new Random().nextDouble()+""); $v = this.requestGet($url);
String $status = RegexUtil.replaceStartEnd($v, "'", "'");
String $verify = RegexUtil.replaceStartEnd($v, ",'", "'");
String $hexqq = RegexUtil.replaceStartEnd($v, ",'\\\\x", "'");
//如果有验证码,一定要在密码加密前搞定哟
if($verify.length()>5){
System.out.println("请进入"+Util.root+"\\verifyTemp\\verify.jpg"+"查看验证码,且在控制台输入验证码→回车");
$url = "http://captcha.qq.com/getimage?uin={0}&aid={1}&{2}";
$url = Util.fillString($url, $uin, $aid, new Random().nextDouble()+"");
this.requestDownload($url, Util.root+"\\verifyTemp\\verify.jpg");
//不解释,控制台输入验证码,突然感觉自己好水话又说回来,如果使用B/S架构,这里还要重构。。额,好吧
File inputFile = new File(Util.root+"\\verifyTemp\\verify.jpg");
FileInputStream os = null;
try {
os = new FileInputStream(inputFile);
} catch (FileNotFoundException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
try {
lab.setIcon(new ImageIcon(ImageIO.read(os)));
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
postBut.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0){
if(arg0.getSource()==postBut){
// $verify = image.getText();
}
}
});
Scanner scanner = new Scanner(System.in);
$verify = scanner.nextLine();
}
//获取加密后的密码
$password = Security.GetPassword($hexqq,$password,$verify);现在是gui界面能显示图片,我如果还在控制台那里输入,是可以的,但是我希望在JTextField这里输入,然后点按钮继续执行,可是// $verify = image.getText(); 这句代码有问题,提示不能引用非终态变量,我把变量加了final也不行,还提示:不能对终态局部变量verify赋值,原因是它是在外层类型中定义的。不知道该怎么解决这个问题了,请高手们指点。
获取验证码部分要与登录的后半部分拆开。 //验证码
String imagePath = Util.root+"\\verifyTemp\\verify.jpg";
ImageIcon image = new ImageIcon(imagePath); //换成图片路径试下。
verificationImage = new JLabel(image);
verificationImage.setBounds(150, 100, 80, 30);
frame.getContentPane().add(verificationImage);
frame.getContentPane()..repaint();
多谢兄弟的指点,真是麻烦你了,都不好意思了。
大家去看http://blog.sina.com.cn/s/blog_533587770101iz4f.html吧,我已经测试过了,可以实现的。