-
慕码人2483693
您只需发出一个提取请求并从 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 Promisefunction 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); })}
-
交互式爱情
https://api.roblox.com/users/get-by-username?username=UserName如果你想在此处使用 js,只需向它发送一个获取请求就非常简单。var requestOptions = { method: 'GET', redirect: 'follow'};fetch("https://api.roblox.com/users/get-by-username?username=xLeki", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error));```
-
浮云间
导入请求导入 jsondef get_user_id(用户名):url = 'https://users.roblox.com/v1/usernames/users'# Request body as a JSON stringrequest_body = { 'usernames': [username], 'excludeBannedUsers': True}json_data = json.dumps(request_body)headers = { 'Content-Type': 'application/json', 'Accept': 'application/json'}response = requests.post(url, headers=headers, data=json_data)user_data = json.loads(response.text)if len(user_data['data']) > 0: user_id = user_data['data'][0]['id'] return user_idelse: return Noneusername = 'lilboii36' user_id = get_user_id(username) if user_id: print(f"User ID for {username}: {user_id}") else: print(f"No user found with username {username}")
-
ABOUTYOU
您可以使用Players:GetUserIdFromNameAsync()
-
SMILET
获取您可以使用的用户名https://users.roblox.com/v1/users/<USER ID>,同时获取您需要的用户状态https://users.roblox.com/v1/users/<USER ID>/status。