介绍

可通过此接口查询自己QQ好友的亲密度,添加时间,共同好友,共同群等信息,需要配合自己QQ的cookie进行查询,相关getGTK,token等算法请参考下方本站博文

PHP实例代码

<?php
$select_qq = '1900432277';
$cookie='p_uin=o'.$qq.'; uin=o'.$qq.'; skey='.$skey.'; p_skey='.$pskey.'';
$url='https://user.qzone.qq.com/proxy/domain/r.qzone.qq.com/cgi-bin/friendship/cgi_friendship?activeuin='.$qq.'&passiveuin='.$select_qq.'&situation=1&g_tk='.getGTK($skey).'&qzonetoken='.getToken($superkey).'&g_tk='.getGTK($skey);
$return=get_curl($url,0,$url,$cookie);
preg_match("/{\"addFriendTime\":(.*?),/sS",$return,$data);
//好友天数
if($data) {
    preg_match("/nick\":{\"(.*?)\":\"(.*?)\",\"(.*?)\":\"(.*?)\"/sS",$return,$nick);
    //好友名称
    preg_match("/friend\":\[(.*?)\]/sS",$return,$friend);
    //共同好友
    preg_match("/group\":\[(.*?)\]/sS",$return,$group);
    //共同群
    preg_match("/intimacyScore\":(.*?),/sS",$return,$intimacyScore);
    //亲密度
    if(array_search($qqq,$nick) == 1) {
        $nick = $nick[1].' - '.$nick[2];
    } elseif(array_search($qqq,$nick) == 3) {
        $nick = $nick[3].' - '.$nick[4];
    }
    $gnum = substr_count($group[1],'name');
    //共同群
    $fnum = explode(',',$friend[1]);
    //共同好友
    $time = time() - $data[1];
    $day = intval($time/86400)+1;
    exit('{"code":1,"msg":"获取成功","qq":"'.$nick[1].'","qmd":"'.$intimacyScore[1].'","addtime":"'.date('Y-m-d H:i:s',$data[1]).'","haoyou":"'.count($fnum).'","qun":"'.$gnum.'","day":"'.$day.'"}');
} else {
    exit('{"code":0,"msg":"对方不是您的好友"}');
}
?>

最后修改:2021 年 09 月 16 日
如果觉得我的文章对你有用,请随意赞赏