根据article https://discord.com/developers/docs/reference#image-data,你得到用户的id
并请求用户的头像数据。看起来像string
。以下是请求的 JSON 响应示例:
{
"id": "80351110224678912",
"username": "Nelly",
"discriminator": "1337",
"avatar": "8342729096ea3675442027381ff50dfe",
"verified": true,
"email": "[email protected] /cdn-cgi/l/email-protection",
"flags": 64,
"premium_type": 1,
"public_flags": 64
}
现在当你得到这个:"avatar": "8342729096ea3675442027381ff50dfe"
,你知道头像数据是8342729096ea3675442027381ff50dfe
。之后,您将为图像使用 Image Base Url:https://cdn.discordapp.com/
.
要请求图像,您必须选择格式(jpg、gif、png 等)。所以你的最终请求应该是:
https://cdn.discordapp.com/avatars/{user_id}/{user_avatar}.png
where user_id
and user_avatar
是要改变的变量。例如:
https://cdn.discordapp.com/avatars/80351110224678912/8342729096ea3675442027381ff50dfe.png