요약
메서드
GenerateItemListAsync(generateRecommendationItemListRequest: Dictionary):RecommendationPages |
GetRecommendationItemAsync(itemId: string):Dictionary |
LogActionEvent(actionType: Enum.RecommendationActionType,itemId: string,tracingId: string,actionEventDetails: Dictionary):() |
LogImpressionEvent(impressionType: Enum.RecommendationImpressionType,itemId: string,tracingId: string,impressionEventDetails: Dictionary):() |
LogPreferenceEvent(preferenceType: Enum.RecommendationPreferenceType,targetType: Enum.RecommendationPreferenceTargetType,targetId: string,tracingId: string,itemId: string):() |
RegisterItemAsync(player: Player,registerRecommendationItemsRequest: Dictionary):Dictionary |
RemoveItemAsync(itemId: string):() |
UpdateItemAsync(updateRecommendationItemRequest: Dictionary):() |
상속된 멤버
API 참조
메서드
GenerateItemListAsync
RecommendationService:GenerateItemListAsync(generateRecommendationItemListRequest:Dictionary):RecommendationPages
매개 변수
코드 샘플
추천 항목 목록 생성하기
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
매개 변수
코드 샘플
단일 추천 항목 가져오기
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(" CustomTags: ")
for _, customTag in ipairs(item.CustomTags) do
print(" " .. customTag)
end
end
else
warn("항목을 검색하지 못했습니다: " .. itemId .. ". 오류: " .. tostring(item))
end
end
-- 예제 사용법 (유효한 itemId 필요)
-- getItem("some-item-id")LogActionEvent
RecommendationService:LogActionEvent(
actionType:Enum.RecommendationActionType, 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
RecommendationService:LogImpressionEvent(
impressionType:Enum.RecommendationImpressionType, 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("아이템에 대한 '뷰' 노출 기록: " .. itemId)
end
-- 사용 예시 (GenerateItemListAsync에서 유효한 itemId와 tracingId가 필요합니다)
-- logView("some-item-id", "some-tracing-id")LogPreferenceEvent
RecommendationService:LogPreferenceEvent(
preferenceType:Enum.RecommendationPreferenceType, targetType:Enum.RecommendationPreferenceTargetType, targetId:string, tracingId:string, itemId:string
):()
매개 변수
반환
()
RegisterItemAsync
RecommendationService:RegisterItemAsync(
매개 변수
코드 샘플
새 항목 등록
local RecommendationService = game:GetService("RecommendationService")
local storage = game:GetService("ReplicatedStorage")
-- ReplicatedStorage에 'RegisterItemRemote'라는 이름의 RemoteFunction이 존재한다고 가정합니다.
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
endRemoveItemAsync
매개 변수
반환
()
코드 샘플
아이템 제거하기
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
endUpdateItemAsync
매개 변수
반환
()
코드 샘플
항목 업데이트
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("업데이트할-항목-id")