Secret
Hiển Thị Bản Đã Lỗi Thời
*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.
Loại dữ liệu Secret lưu trữ nội dung bí mật được trả về bởi HttpService:GetSecret() .Nó không thể được in hoặc ghi nhận, nhưng có thể được sửa đổi bằng cách sử dụng các chức năng tích hợp sẵn:
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)
Tóm Tắt
Phương Pháp
AddPrefix
Trả về một bí mật được hình thành bằng cách kết hợp chuỗi cung cấp vào nội dung bí mật, ví dụ dùng "Bearer" để đặt chìa khóa API.
local HttpService = game:GetService("HttpService")local secret = HttpService:GetSecret("yelp")local authHeader = secret:AddPrefix("Bearer ")
Tham Số
Lợi Nhuận
AddSuffix
Trả về một bí mật được hình thành bằng cách kết hợp bí mật ban đầu và tham số chuỗi được cung cấpHữu ích khi tạo một URL chứa một chìa khóa và tham số truy vấn.
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)