Html 通过用户名获取ID(Roblox)

Html 通过用户名获取ID(Roblox),html,api,roblox,Html,Api,Roblox,我想知道如何通过发送请求,但似乎没有具体记录。 我正在通过status登录站点,我需要ID来获取用户状态。我感谢你给予的任何帮助 如果我绝对需要使用/v1/user/search,我想获取第一个用户的id。您可以使用或 这些可能是不正确的,因为游戏网站被我屏蔽了:(要获取用户名,您可以使用https://users.roblox.com/v1/users/,同时获取所需用户的状态https://users.roblox.com/v1/users//status您只需发出获取请求并从URL获取用

我想知道如何通过发送请求,但似乎没有具体记录。 我正在通过status登录站点,我需要ID来获取用户状态。我感谢你给予的任何帮助


如果我绝对需要使用
/v1/user/search
,我想获取第一个用户的id。

您可以使用或


这些可能是不正确的,因为游戏网站被我屏蔽了:(

要获取用户名,您可以使用
https://users.roblox.com/v1/users/
,同时获取所需用户的状态
https://users.roblox.com/v1/users//status

您只需发出获取请求并从URL获取用户ID即可

function getUserID(name)
{
    return new Promise((res, rej) => {
        fetch(`https://www.roblox.com/users/profile?username=${name}`)
            .then(r => {
                // check to see if URL is invalid.
                if (!r.ok) { throw "Invalid response"; }
                // return the only digits in the URL "the User ID"
                return r.url.match(/\d+/)[0];
            })
            .then(id =>{
                // this is where you get your ID
                console.log(id);
            })
    })
}

// without Promise

function getUserID(name)
{
    fetch(`https://www.roblox.com/users/profile?username=${name}`)
        .then(r => {
            if (!r.ok) { throw "Invalid response"; }
            return r.url.match(/\d+/)[0];
        })
        .then(id => {
            console.log(id);
        })
}

很抱歉,我不熟悉在StackOverflow上发布答案。如果您需要任何帮助,请随时询问。

我不是在找lua,但无论如何,谢谢您!