返回首页

QQ头像加密地址获取

接口说明

QQ头像加密地址获取

接口基本信息

API地址

https://api.cenguigui.cn/api/qq/qq.php

请求方式

GET

返回格式

JSON

接口状态

正常启用

参数说明

以下参数为接口所需调用信息

参数 是否必填 说明
QQ头像加密地址获取qq?qq=QQ号

请求示例

HTTP请求

https://api.cenguigui.cn/api/qq/qq.php?qq=778713968

返回结果

HTTP 200 OK
{ "code": "200", "msg": "请求成功", "avatar_url": "https://thirdqq.qlogo.cn/g?b=sdk&k=fMjf65dwcz9xnsOCpCmkyQ&kti=ZLj6nAAAAAI&s=100&t=1681886018", "info": { "request": { "state": "a279d3a6df4fcee17e82fc70b380bdcc", "request_id": "64b8fa9cc95fb", "method": "GET", "api_id": "1", "api_action": "UserInfo", "api_title": "QQ头像加密地址获取", "api_name": "qq头像地址为加密版,不会透露出QQ号。", "query": { "qq": "778713968" }, "cdn_node": "当前请求由阿里云CDN加速" }, "developer": { "author": "笒鬼鬼", "home": "https://www.cenguigui.cn", "mail": "cengugiui@qq.com", "notice": "交流Q群 695288151", "time": "2023-07-20 17:13:00" } } }

调用示例

<!--html示例-->
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>获取头像</title>
</head>
<body>
    <h1>获取头像</h1>
    
    <div id="guigui_avatar"></div>

    <script>
        // 使用XMLHttpRequest发送GET请求获取头像信息
        var xhr = new XMLHttpRequest();
        xhr.open("GET", "https://api.cenguigui.cn/api/qq/qq.php?qq=778713968", true);
        xhr.onreadystatechange = function () {
            if (xhr.readyState === 4 && xhr.status === 200) {
                var response = JSON.parse(xhr.responseText);
                
                if (response.code === "200" && response.avatar_url) {
                    var avatarUrl = response.avatar_url;
                    var imageElement = document.createElement("img");
                    imageElement.src = avatarUrl;
                    document.getElementById("guigui_avatar").appendChild(imageElement);
                } else {
                    console.error("获取头像失败: " + response.msg);
                }
            }
        };
        xhr.send();
    </script>
</body>
</html>

示例代码