无法正确获取用户状态 - Roblox API

发布于 2025-01-10 15:23:32 字数 1827 浏览 0 评论 0原文

我正在开发一个 Chrome 扩展程序,根据您在 Roblox 网站上所做的操作来设置您的 Discord Rich Presence 状态,并且我想检测用户是否正在玩游戏。但是,Roblox 的 Presence API 似乎无法正常工作。

当我在 API 站点上为其提供用户 ID 时,它会正确返回当前玩的游戏,但是当我运行它生成的 cURL 命令时,它不会返回 universeIdgameIdrootPlaceIdplaceIdlastLocation

这是网站生成的响应:

{
  "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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

¢好甜 2025-01-17 15:23:32

确保在您的请求标头中包含 .ROBLOSECURITY Cookie。

这就是 CURL 中的样子:

curl -X 'POST' 'https://presence.roblox.com/v1/presence/users' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Cookie: .ROBLOSECURITY=_|WARNING:-DO-NOT-SHARE-THIS.--Sharing-this-will-allow-someone-to-log-in-as-you-and-to-steal-your-ROBUX-and-items.|' \
-d '{
    "userIds": [
       373806907
    ]
}'

Make sure to include the .ROBLOSECURITY Cookie within your request's header.

This is how it would look like within CURL:

curl -X 'POST' 'https://presence.roblox.com/v1/presence/users' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Cookie: .ROBLOSECURITY=_|WARNING:-DO-NOT-SHARE-THIS.--Sharing-this-will-allow-someone-to-log-in-as-you-and-to-steal-your-ROBUX-and-items.|' \
-d '{
    "userIds": [
       373806907
    ]
}'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文