PHP获取qq信息和头像等资料
<?php
//获取QQ昵称QQ头像if ($_GET['qq']) {
$qq = $_GET['qq'];
//向接口发起请求获取json数据
//http://users.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg?uins=909009107
$get_info = file_get_contents('http://r.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg?get_nick=1&uins='.$qq); //获取QQ信息//转换编码
$get_info = mb_convert_encoding($get_info, "UTF-8", "GBK");
//对获取的json数据进行截取并解析成数组
$name = json_decode(substr($get_info,17,-1),true);
if($name and $qq){
$txUrl = 'https://q.qlogo.cn/headimg_dl?dst_uin='.$qq.'&spec=100'; //获取QQ头像
$arr = array(
'code' => 1,
'imgurl' => $txUrl,
'name' => urlencode($name[$qq][6])
);
exit(stripslashes(urldecode(json_encode($arr))));
}else{
$arr = array(
'code' => -1,
'msg' => 'Error'
);
exit(stripslashes(urldecode(json_encode($arr))));
}
}else{
$arr = array(
'code' => -1,
'msg' => 'Error'
);
exit(stripslashes(urldecode(json_encode($arr))));
}
?>
代用方式:www.xxxx.com/xx.php?qq=QQ号
- 版权申明:此文如未标注转载均为本站原创,自由转载请表明出处《龙行博客》。
- 本文网址:https://www.liaotaoo.cn/212.html
- 上篇文章:PHP使用tcpdf类生成PDF文件
- 下篇文章:php新浪短网址API调用生成短网址