欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

java 判断qq_Java检测QQ是否在线状态

发布时间:2024/9/3 40 豆豆
生活随笔 收集整理的这篇文章主要介绍了 java 判断qq_Java检测QQ是否在线状态 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

腾讯QQ在线状态 WEB 服务Endpoint:http://www.webxml.com.cn/webservices/qqOnlineWebService.asmxDisco:http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx?discoWSDL:http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl

通过输入QQ号码(String)检测QQ在线状态。返回数据(String)Y = 在线;N = 离线 ;E = QQ号码错误......

Email 电子邮件地址验证 WEB 服务Endpoint:http://www.webxml.com.cn/WebServices/ValidateEmailWebService.asmxDisco:http://www.webxml.com.cn/WebServices/ValidateEmailWebService.asmx?discoWSDL:http://www.webxml.com.cn/WebServices/ValidateEmailWebService.asmx?wsdl

Email 电子邮件地址验证 Web Service,通过查找给定的电子邮件域的邮件服务器和通过向邮件服务器发送数据来判断电子邮件地址正确与否。此Email地址验证Web Service请不要用于任何商业目的

Java代码:

public class ValidatedQQOnline {

public static void main(String[] args) {

while(true) {

System.out.println("请输入要查询的QQ号码、输入“0”退出");

java.util.Scanner in=new java.util.Scanner(System.in);

String qq = in.next();

if(qq.equals("0")){

break;

}

String result = "";

String charset = "UTF-8";

String callurl = "http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx/qqCheckOnline?qqCode=";

try {

/*

* 通过输入QQ号码(String)检测QQ在线状态。 返回数据(String)Y = 在线;N = 离线 ;E =

* QQ号码错误

*/

java.net.URL url = new java.net.URL(callurl + qq);

java.net.URLConnection connection = url.openConnection();

connection.connect();

java.io.BufferedReader reader = new java.io.BufferedReader(

new java.io.InputStreamReader(connection

.getInputStream(), charset));

String line;

/*

* 返回的格式 <?xml version="1.0" encoding="utf-8"?>

* xmlns="http://WebXml.com.cn/">E

*/

while ((line = reader.readLine()) != null) {

result += line;

result += "\n";

}

} catch (Exception e) {

e.printStackTrace();

}

int len = result.indexOf("\">");

if (len != -1) {

String qStruts = result.substring(len + 2, len + 3);

if (qStruts.equals("E")) {

System.out.println("QQ号码错误");

} else if (qStruts.equals("Y")) {

System.out.println("在线");

} else if (qStruts.equals("N")) {

System.out.println("离线");

}

} else {

System.out.println("服务器繁忙、请从试!");

}

}

}

}

总结

以上是生活随笔为你收集整理的java 判断qq_Java检测QQ是否在线状态的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。