名称 | 必填 | 类型 | 说明 |
---|---|---|---|
QQ头像加密地址获取 | 是 | ?qq=QQ号 |
{ "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>
赞助一下