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

c113a11be6f7d9a16820983c79ffb2fd.gif

通过输入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

7be8d4dc7ec97494d6ebf51770b7d192.gif

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("服务器繁忙、请从试!");

}

}

}

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值