Secret

顯示已棄用項目

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡

Secret 數據類型儲存由 HttpService:GetSecret() 返回的秘密內容。它不能被列印或記錄,但可以使用內置功能進行修改:


local HttpService = game:GetService("HttpService")
local mySiteApiKey = HttpService:GetSecret("my_site")
local url = "https://apis.mysite.com?apiKey="
local urlWithKey = mySiteApiKey:AddPrefix(url)
local params = "&request=join&user=myname"
local resultingUrl = urlWithKey:AddSuffix(params)

概要

方法

方法

AddPrefix

返回由供應的字串與秘密內容組合形成的秘密,例如將 "Bearer" 添加到 API 鑰鍵。


local HttpService = game:GetService("HttpService")
local secret = HttpService:GetSecret("yelp")
local authHeader = secret:AddPrefix("Bearer ")

參數

prefix: string

返回

AddSuffix

返回由原始秘密和提供的字串參數連接形成的秘密。創建包含鑰匙和查詢參數的 URL 時有用。


local HttpService = game:GetService("HttpService")
local googleMapsApiKey = HttpService:GetSecret("google_map")
local baseUrl = "https://maps.googleapis.com/maps/api/distancematrix/json?key="
local queryParams = "&destinations=" .. destination .. "&origins=" .. origin .. "&departure_time=now&units=imperial"
local authedUrl = googleMapsApiKey:AddPrefix(baseUrl)
local queryUrl = authedUrl:AddSuffix(queryParams)

參數

suffix: string

返回