【iAPP教程】获取QQ昵称代码! |
|
请叫我淫贼
L3
• 2019-09-30 • 回复 5 • 只看楼主
• 举报
|
新建 module.mjava 界面:
/*
* 获取QQ昵称
* @Param qq QQ号码
*/String getNick(String qq){
// 获取QQ昵称
if(sss("NickData") != null){
String nick = i.json(sss("NickData"), "get", qq);
if(nick != null) return nick;
}
String url = "http://users.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg";
String data = "uins="+qq;
String webdata = post(url, data, "gbk");
webdata = i.sj(webdata, "(", ")");
Object j = i.json(webdata);
j = i.json(j, "get", qq);
String nick = i.json(j, "get", "6");
// 添加缓存
if(sss("NickData") == null){
sss("NickData", i.json("{}"));
i.json(sss("NickData"), "set", qq, nick);
}
return nick;}/*
* post提交
* @Param url 链接
* @Param data POST数据
* @Param encode 编码方式
*/String post(String url, String data, String encode){
Boolean end = false;
String webdata = null;
i.t(
new com.iapp.interfaces.OnThread(){
public void run(){
webdata = i.hs(url, data, encode);
}
});
while(end != true){
if(webdata != null){
return webdata;
}
}}
/*
* 获取QQ昵称
* @Param qq QQ号码
*/String getNick(String qq){
// 获取QQ昵称
if(sss("NickData") != null){
String nick = i.json(sss("NickData"), "get", qq);
if(nick != null) return nick;
}
String url = "http://users.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg";
String data = "uins="+qq;
String webdata = post(url, data, "gbk");
webdata = i.sj(webdata, "(", ")");
Object j = i.json(webdata);
j = i.json(j, "get", qq);
String nick = i.json(j, "get", "6");
// 添加缓存
if(sss("NickData") == null){
sss("NickData", i.json("{}"));
i.json(sss("NickData"), "set", qq, nick);
}
return nick;}/*
* post提交
* @Param url 链接
* @Param data POST数据
* @Param encode 编码方式
*/String post(String url, String data, String encode){
Boolean end = false;
String webdata = null;
i.t(
new com.iapp.interfaces.OnThread(){
public void run(){
webdata = i.hs(url, data, encode);
}
});
while(end != true){
if(webdata != null){
return webdata;
}
}}
// 建议调用时加t线程操作,访问接口会有1-3秒延迟
call(nick, "mjava", "module.getNick", "QQ号")//左边是QQ号
tw(nick)