无法正确获取用户状态 - Roblox API
我正在开发一个 Chrome 扩展程序,根据您在 Roblox 网站上所做的操作来设置您的 Discord Rich Presence 状态,并且我想检测用户是否正在玩游戏。但是,Roblox 的 Presence API 似乎无法正常工作。
当我在 API 站点上为其提供用户 ID 时,它会正确返回当前玩的游戏,但是当我运行它生成的 cURL 命令时,它不会返回 universeId
、gameId
、rootPlaceId
、placeId
或 lastLocation
。
这是网站生成的响应:
{
"userPresences": [
{
"userPresenceType": 2,
"lastLocation": "[Leaderboards!] The Rake REMASTERED",
"placeId": 2413927524,
"rootPlaceId": 2413927524,
"gameId": "436735c2-7010-4dd0-83a1-0e3af1510779",
"universeId": 847722000,
"userId": 1843923756,
"lastOnline": "2022-02-28T14:56:06.823Z"
}
]
}
网站生成的 cURL 命令:
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{ \
"userIds": [ \
1843923756 \
] \
}' 'https://presence.roblox.com/v1/presence/users'
这是 cURL 命令返回的内容:
{
"userPresences": [{
"userPresenceType": 2,
"lastLocation": "",
"placeId": null,
"rootPlaceId": null,
"gameId": null,
"universeId": null,
"userId": 1843923756,
"lastOnline": "2022-02-28T14:56:06.823Z"
}]
}
我能想到的唯一解决方案是使用 Roblox 的旧版存在 API (https://api.roblox.com/Users/1843923756/OnlineStatus),但我无法在 Roblox 网站上访问它。
No 'Access-Control-Allow-Origin' header is present on the requested resource.
I am developing a Chrome extension that sets your Discord Rich Presence status based on what you're doing on the Roblox website, and I want to detect if the user is playing a game. However, Roblox's Presence API doesn't seem to be working correctly.
When I give it a user ID on the API site, it returns the currently played game correctly, but when I run the cURL command it generates it does not return the universeId
, gameId
, rootPlaceId
, placeId
, or lastLocation
.
Here's the response generated by the website:
{
"userPresences": [
{
"userPresenceType": 2,
"lastLocation": "[Leaderboards!] The Rake REMASTERED",
"placeId": 2413927524,
"rootPlaceId": 2413927524,
"gameId": "436735c2-7010-4dd0-83a1-0e3af1510779",
"universeId": 847722000,
"userId": 1843923756,
"lastOnline": "2022-02-28T14:56:06.823Z"
}
]
}
cURL command generated by the website:
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{ \
"userIds": [ \
1843923756 \
] \
}' 'https://presence.roblox.com/v1/presence/users'
and here's what the cURL command returns:
{
"userPresences": [{
"userPresenceType": 2,
"lastLocation": "",
"placeId": null,
"rootPlaceId": null,
"gameId": null,
"universeId": null,
"userId": 1843923756,
"lastOnline": "2022-02-28T14:56:06.823Z"
}]
}
The only solution I can think of is using Roblox's legacy presence API (https://api.roblox.com/Users/1843923756/OnlineStatus) but I can't access it on the Roblox website.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保在您的请求标头中包含 .ROBLOSECURITY Cookie。
这就是 CURL 中的样子:
Make sure to include the .ROBLOSECURITY Cookie within your request's header.
This is how it would look like within CURL: