链接:
1. http://q1.qlogo.cn/g?b=qq&nk=QQ号码&s=100
2. https://q1.qlogo.cn/g?b=sdk&k=你的k值&s=100
3. http://q2.qlogo.cn/headimg_dl?dst_uin=QQ号码&spec=100有些场景,我们为了隐藏自己的QQ号码需要使用第二种情况。
获取K值:
http://ptlogin2.qq.com/getface?&imgtype=1&uin=QQ号可以获得如图所示的字符串:
k值摆在了面前。
进阶:使用PHP对外提供调用接口
qqtx.php:
<?php 
$qq = $_GET['qq'];
$src = 'https://q1.qlogo.cn/g?b=qq&nk=' . $qq . '&s=100&t=' . time();  
header('Content-type: image/png');  
$res = imagecreatefromstring(file_get_contents($src)); 
imagepng($res); 
imagedestroy($res); 
?>调用方法:
http://域名/qqtx.php?qq=QQ号图片大小:
目前发现tx提供有40、100、140、640几种。
封面图片:
www.elharrakfonts.com/2019/01/tencent-qq.html
灵感来源:
catiz.cn/links.html
www.jianshu.com/p/42d0ada1c5cf
qqdie.com/archives/get-qq-avatar-no-qq-number.html
www.yangbt.com/api/41.html
6.11更新:
Handsome评论区解析QQ头像链接不暴露QQ号:
挣扎了近18小时,终于出坑!
    //尝试隐藏QQ号的函数
      public static function qqgravatar ($object){
          /*$options = mget();
        header('Content-type: text/json');
        $qqurl='https://ptlogin2.qq.com/getface?uin=' . $uin . '&imgtype=3';
        $qqhtml = file_get_contents($qqurl);
        $qqpattern = '#https://.*s=100#';
        preg_match($qqpattern,$qqhtml,$match);
        $imgurl = $match[0]; 
        return $imgurl;*/
        $apiurl = "https://ptlogin2.qq.com/getface?appid=1006102&uin=" . $object . "&imgtype=3";
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $apiurl);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        $data = curl_exec($ch);
        curl_close($ch);
        $avatar = $data;
        $pattern2 = '/pt.setHeader\((.*)\)/is';
        preg_match($pattern2, $avatar, $result2);
        return json_decode($result2[1], true)["$object"];
      }
  
    public static function getAvator($email,$size){
        $options = mget();
        $cdnUrl = $options->CDNURL;
        if (@ in_array('emailToQQ',$options->featuresetup)){
            $str = explode('@', $email);
            if (@$str[1] == 'qq.com' && @ctype_digit($str[0]) && @strlen($str[0]) >=5
                && @strlen($str[0])<=11) {
                //$avatorSrc = 'https://q.qlogo.cn/g?b=qq&nk='.$str[0].'&s=100';
                  $avatorSrc = Utils::qqgravatar($str[0]);
            }else{
                $avatorSrc = Utils::getGravator($email,$cdnUrl,$size);
            }
        }else{
            $avatorSrc = Utils::getGravator($email,$cdnUrl,$size);
        }
        return $avatorSrc;
    }
灵感来源:
qqdie.com/archives/get-qq-avatar-no-qq-number.html
www.php.net/manual/zh/function.file-get-contents.php
monsterx.cn/Front-end/Gravatar-to-QQ.html
版权属于:soarli
本文链接:https://blog.soarli.top/archives/422.html
转载时须注明出处及本声明。
 
