我正在 steam 中尝试 GET 请求 ( GetUserStatsForGame ) (https://partner.steamgames.com/doc/webapi/ISteamUserStats)
这是我的 apiUrl =“https://partner.steam-api.com/ISteamUserStats/GetUserStatsForGame/v2/?key={{apiKey}}&steamid={{steamId}}&appid={{appIdCS2}}”
提前感谢您帮助解决我的问题😃
我在postman中尝试过,我希望得到XML格式的响应。
在邮递员中仔细检查您的 API 密钥是否已正确设置为变量。如果将鼠标悬停在
{{apiKey}}
上,您可以对其进行编辑并确认。您也可以对其进行硬编码,如下所示。为了确保它是 xml 格式,请在 url 末尾添加 &format=xml
。
https://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v2/?key=PASTEKEYHERE&steamid=PASTEID&appid=PASTEAPPID&format=xml
如果您在 javascript 中执行此操作,它可能看起来像这样,但请注意,我将
{{VARIABLE}}
更改为 ${variable}
以便动态地将变量值插入到字符串中。
// Replace these placeholders with your actual values
const apiKey = 'YOUR_ACTUAL_API_KEY';
const steamId = 'YOUR_STEAM_ID';
const appIdCS2 = 'YOUR_APP_ID';
https://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v2/?key=${apiKey}&steamid=${steamId}&appid=${appIdCS2}&format=xml
我用自己的 API 密钥测试了它们,它似乎按预期工作。