环境为PHP7.2
以下为代码
符合本站点主题使用 也可以应用到其他地方。

<?php
use RingCentral\Psr7\Response;

function handler($request, $context): Response{
    $queries    = $request->getQueryParams();
    $respHeaders= array('Content-Type' => 'application/json');
    $type       = $queries['type'];
    $qqnumber   = $queries['qqnumber'];
    $respBody   = null;
    if($type === 'getqqnickname'){
    $qq = $qqnumber ?: '';
        if(!empty($qq) && is_numeric($qq) && strlen($qq) > 4 && strlen($qq) < 13){
            $qqnickname = file_get_contents('https://r.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg?g_tk=1518561325&uins='.$qq); // API
            if($qqnickname){
                try{
                $qqnickname = iconv('GBK','UTF-8',$qqnickname);
                }catch(Exception $e){}
                $respBody = str_replace(['portraitCallBack(','_Callback(',')',';'],'',$qqnickname);
            }
        }
    }

    if($type === 'getqqavatar'){
        $qq = $qqnumber ?: '';
        if(!empty($qq) && is_numeric($qq) && strlen($qq) > 4 && strlen($qq) < 13){
            $qqavatar = file_get_contents('https://ptlogin2.qq.com/getface?appid=1006102&imgtype=3&uin='.$qq);  // API
            if($qqavatar){
                $respBody = str_replace(['pt.setHeader(',')'],'',$qqavatar);
            }
        }
    }
    $check = json_decode($respBody,true);
    if (isset($check['error']) || !isset($respBody) || !isset($check[$qqnumber])){
        return new Response(400, $respHeaders, null);
    }else {
        return new Response(200, $respHeaders, $respBody);
    }
}

沉淪在無盡的深淵當中...