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

ส่งค่ากลับ