第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

通過用戶名獲取 ID (Roblox)

通過用戶名獲取 ID (Roblox)

郎朗坤 2023-06-15 17:17:56
我想知道如何通過ROBLOX 的用戶 API發(fā)送請求,但似乎沒有具體記錄。我正在通過狀態(tài)登錄網(wǎng)站,我需要 ID 來獲取用戶狀態(tài)。感謝您提供的任何幫助。如果我絕對需要使用/v1/user/search,我想獲得第一個用戶的 id。
查看完整描述

5 回答

?
慕碼人2483693

TA貢獻1860條經(jīng)驗 獲得超9個贊

您只需發(fā)出一個提取請求并從 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);

? ? ? ? })

}


查看完整回答
反對 回復 2023-06-15
?
交互式愛情

TA貢獻1712條經(jīng)驗 獲得超3個贊

https://api.roblox.com/users/get-by-username?username=UserName如果你想在此處使用 js,只需向它發(fā)送一個獲取請求就非常簡單。




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));```


查看完整回答
反對 回復 2023-06-15
?
浮云間

TA貢獻1829條經(jīng)驗 獲得超4個贊

導入請求導入 json


def get_user_id(用戶名):


url = 'https://users.roblox.com/v1/usernames/users'


# Request body as a JSON string

request_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_id

else:

    return None

username = '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}")


查看完整回答
反對 回復 2023-06-15
?
ABOUTYOU

TA貢獻1812條經(jīng)驗 獲得超5個贊

您可以使用Players:GetUserIdFromNameAsync()

查看完整回答
反對 回復 2023-06-15
?
SMILET

TA貢獻1796條經(jīng)驗 獲得超4個贊

獲取您可以使用的用戶名https://users.roblox.com/v1/users/<USER ID>,同時獲取您需要的用戶狀態(tài)https://users.roblox.com/v1/users/<USER ID>/status。



查看完整回答
反對 回復 2023-06-15
  • 5 回答
  • 0 關注
  • 354 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號