学ぶ
エンジンクラス
RecommendationService
作成できません
サービス

*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。


概要
方法
GenerateItemListAsync(generateRecommendationItemListRequest: Dictionary):RecommendationPages
LogActionEvent(actionType: Enum.RecommendationActionType,itemId: string,tracingId: string,actionEventDetails: Dictionary):()
LogImpressionEvent(impressionType: Enum.RecommendationImpressionType,itemId: string,tracingId: string,impressionEventDetails: Dictionary):()
RegisterItemAsync(player: Player,registerRecommendationItemsRequest: Dictionary):Dictionary
UpdateItemAsync(updateRecommendationItemRequest: Dictionary):()
継承されたメンバー

APIリファレンス
方法
GenerateItemListAsync
イールド
機能: Basic
RecommendationService:GenerateItemListAsync(generateRecommendationItemListRequest:Dictionary):RecommendationPages
パラメータ
generateRecommendationItemListRequest:Dictionary
コードサンプル
推奨アイテムのリストを生成する
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)

GetRecommendationItemAsync
イールド
機能: Basic
RecommendationService:GetRecommendationItemAsync(itemId:string):Dictionary
パラメータ
itemId:string
戻り値
コードサンプル
単一の推薦アイテムを取得する
local RecommendationService = game:GetService("RecommendationService")
local function getItem(itemId)
local success, item = pcall(function()
return RecommendationService:GetRecommendationItemAsync(itemId)
end)
if success and item then
print("成功裏にアイテムを取得しました: " .. item.ItemId)
print(" ReferenceId: " .. item.ReferenceId)
-- 単一のアイテムを直接取得する際、TracingIdは空になります
if item.Creator then
print(" CreatorId: " .. tostring(item.Creator.CreatorId))
end
if item.CustomTags then
print(" カスタムタグ: ")
for _, customTag in ipairs(item.CustomTags) do
print(" " .. customTag)
end
end
else
warn("アイテムの取得に失敗しました: " .. itemId .. ". エラー: " .. tostring(item))
end
end
-- 使用例(有効な itemId が必要です)
-- getItem("some-item-id")

LogActionEvent
機能: Basic
RecommendationService:LogActionEvent(
actionType:Enum.RecommendationActionType, itemId:string, tracingId:string, actionEventDetails:Dictionary
):()
パラメータ
itemId:string
tracingId:string
actionEventDetails:Dictionary
既定値: "nil"
戻り値
()
コードサンプル
ユーザーアクションのログ
local RecommendationService = game:GetService("RecommendationService")
local function logLike(itemId, tracingId)
local detail: RecommendationActionEventDetails = {
ReactionType = "Like",
Weight = 1.0
}
RecommendationService:LogActionEvent(Enum.RecommendationActionType.AddReaction, itemId, tracingId, detail)
print("アイテムの 'Like' アクションをログしました: " .. itemId)
end
-- 例の使用法(GenerateItemListAsync からの有効な itemId と tracingId が必要)
-- logLike("item-id", "tracing-id")

LogImpressionEvent
機能: Basic
RecommendationService:LogImpressionEvent(
impressionType:Enum.RecommendationImpressionType, itemId:string, tracingId:string, impressionEventDetails:Dictionary
):()
パラメータ
itemId:string
tracingId:string
impressionEventDetails:Dictionary
既定値: "nil"
戻り値
()
コードサンプル
ユーザーのインプレッションを記録
local RecommendationService = game:GetService("RecommendationService")
local function logView(itemId, tracingId)
local detail: RecommendationImpressionEventDetails = {
Duration = 5, -- ユーザーは5秒間表示しました
ItemPosition = 1,
DepartureIntent = Enum.RecommendationDepartureIntent.Neutral
}
RecommendationService:LogImpressionEvent(Enum.RecommendationImpressionType.View, itemId, tracingId, detail)
print("アイテムの 'View' インプレッションを記録しました: " .. itemId)
end
-- 使用例(GenerateItemListAsyncからの有効な itemId と tracingId が必要です)
-- logView("some-item-id", "some-tracing-id")

LogPreferenceEvent
機能: Basic
RecommendationService:LogPreferenceEvent(
preferenceType:Enum.RecommendationPreferenceType, targetType:Enum.RecommendationPreferenceTargetType, targetId:string, tracingId:string, itemId:string
):()
パラメータ
targetId:string
tracingId:string
itemId:string
戻り値
()

RegisterItemAsync
イールド
機能: Basic
RecommendationService:RegisterItemAsync(
player:Player, registerRecommendationItemsRequest:Dictionary
パラメータ
player:Player
registerRecommendationItemsRequest:Dictionary
戻り値
コードサンプル
新しいアイテムを登録する
local RecommendationService = game:GetService("RecommendationService")
local storage = game:GetService("ReplicatedStorage")
-- 'RegisterItemRemote' という名前の RemoteFunction が ReplicatedStorage に存在すると仮定します
local registerItemRemote = storage.RegisterItemRemote
registerItemRemote.OnServerInvoke = function(player, refId)
local request: RegisterRecommendationItemRequest = {
ContentType = Enum.RecommendationItemContentType.Dynamic,
ReferenceId = refId,
Duration = 60,
Visibility = Enum.RecommendationItemVisibility.Public,
CustomTags = {"locale:en-us", "seasonal:summer"},
Attributes = {
{
AssetId = 123,
Description = "テストビデオ",
TrimStartTime = 0,
TrimEndTime = 10.5
}
}
}
local success, response = pcall(function()
return RecommendationService:RegisterItemAsync(player, request)
end)
if success and response then
print("アイテムが正常に登録されました。 ItemId: " .. response.ItemId)
return response.ItemId
else
warn("アイテムの登録に失敗しました。 エラー: " .. tostring(response))
return nil
end
end

RemoveItemAsync
イールド
機能: Basic
RecommendationService:RemoveItemAsync(itemId:string):()
パラメータ
itemId:string
戻り値
()
コードサンプル
アイテムを削除する
local RecommendationService = game:GetService("RecommendationService")
local function removeItem(itemId)
local success, err = pcall(function()
return RecommendationService:RemoveItemAsync(itemId)
end)
if success then
print("アイテムを正常に削除しました: " .. itemId)
else
warn("アイテムの削除に失敗しました: " .. itemId .. ". エラー: " .. tostring(err))
end
end

UpdateItemAsync
イールド
機能: Basic
RecommendationService:UpdateItemAsync(updateRecommendationItemRequest:Dictionary):()
パラメータ
updateRecommendationItemRequest:Dictionary
戻り値
()
コードサンプル
アイテムを更新する
local RecommendationService = game:GetService("RecommendationService")
local function updateItem(itemId)
-- 更新したいフィールドのみを含めてください
local request: UpdateRecommendationItemRequest = {
ItemId = itemId,
Visibility = Enum.RecommendationItemVisibility.Private,
-- 注意: CustomTagsリスト全体がこの新しいリストで置き換えられます
CustomTags = {"updated-tag"}
}
local success, err = pcall(function()
return RecommendationService:UpdateItemAsync(request)
end)
if success then
print("アイテムを正常に更新しました: " .. itemId)
else
warn("アイテムの更新に失敗しました: " .. itemId .. ". エラー: " .. tostring(err))
end
end
-- 使用例
-- updateItem("some-item-id-to-update")

©2026 Roblox Corporation。Roblox(ロブロックス)、RobloxロゴおよびPowering Imaginationは、米国並びにその他の国における登録商標および非登録商標です。