
PHP获取QQ昵称和头像API
示例地址:https://tenapi.cn/qqname?qq=12345
使用文档:https://docs.tenapi.cn/qqname.html
返回数据
{"code":1,"imgurl":"https://q1.qlogo.cn/headimg_dl?dst_uin=12345&spec=100","name":"一块乐"}
接口源码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| <?php if ($_GET['qq']) { $qq = $_GET['qq']; $get_info = file_get_contents('http://r.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg?get_nick=1&uins='.$qq); $get_info = mb_convert_encoding($get_info, "UTF-8", "GBK"); $name = json_decode(substr($get_info,17,-1),true); if($name and $qq){ $server = rand(1,4); $txUrl = 'https://q'.$server.'.qlogo.cn/headimg_dl?dst_uin='.$qq.'&spec=100'; $arr = array( 'code' => 1, 'imgurl' => $txUrl, 'name' => urlencode($name[$qq][6]) ); $json_string = json_encode($arr); 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)))); }
|