Engine Class
RecommendationPages
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
สรุป
ตัวอย่างโค้ด
สร้างรายการสินค้าแนะนำ
local RecommendationService = game:GetService("RecommendationService")
-- กำหนดคำขอสำหรับการสร้างรายการแนะนำ
local request: GenerateRecommendationItemListRequest = {
ConfigName = "MaximizeEngagement",
LocationId = "Lobby",
PageSize = 10
-- หมายเหตุ: ยกเลิกการคอมเมนต์และตั้งค่า CustomContexts.UserId สำหรับสคริปต์เซิร์ฟเวอร์.
-- ไม่จำเป็นต้องตั้งค่าสำหรับสคริปต์ท้องถิ่น.
-- CustomContexts = {
-- ["UserId"] = tostring(player.UserId),
-- }
}
-- เรียกใช้ GenerateItemListAsync เพื่อรับหน้ารายการแนะนำ
local success, recommendationPages = pcall(function()
return RecommendationService:GenerateItemListAsync(request)
end)
if success then
-- รับหน้าปัจจุบันของสินค้าที่แนะนำ
local currentPage = recommendationPages:GetCurrentPage()
for _, item in ipairs(currentPage) do
print("ItemId: " .. item.ItemId)
print(" ReferenceId: " .. item.ReferenceId)
print(" TracingId: " .. item.TracingId)
end
else
warn("ข้อผิดพลาดของ RecommendationService: " .. tostring(recommendationPages))
end
--[[ รูปแบบข้อมูลที่ส่งกลับสำหรับแต่ละรายการในหน้า
{
"ItemId": string,
"ReferenceId": string,
"TracingId": string,
"Creator": {
"CreatorId": number,
"CreatorType": Enum.CreatorType,
}?,
"Attributes": {
{
"AssetId": number?,
"Text": string?,
"Description": string?,
"SeekStartTime": number?,
"SeekEndTime": number?,
"TrimStartTime": number?,
"TrimEndTime": number?
}
}?,
"CustomTags": { string }?
}
--]]