Datatype.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)
方法
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)