エンジンクラス
RecommendationPages
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
コードサンプル
推奨アイテムのリストを生成する
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 }?
}
--]]