I have this code which should fetch a players gamepasses:
local gamesUrl = "https://games.roproxy.com/v2/%s/%s/games?sortOrder=Asc&limit=50&cursor=%s"
local gamePassesUrl = "https://games.roproxy.com/v1/games/%s/game-passes?sortOrder=Asc&limit=100&cursor=%s"
local baseUrl = "https://catalog.roproxy.com/v1/search/items/details?Category=3&CreatorTargetId=%s&CreatorType=%s&Limit=30&Cursor=%s"
local function getGamesIds(userId, targetType, cursor, gamesIds)
cursor = cursor or ""
gamesIds = gamesIds or {}
local requestUrl = string.format(gamesUrl, targetType, tostring(userId), cursor)
local success, result = pcall(HttpService.GetAsync, HttpService, requestUrl)
if success and result then
local data = HttpService:JSONDecode(result)
for _, properties in pairs(data.data) do
table.insert(gamesIds, properties["id"])
end
if data.nextPageCursor then
getGamesIds(userId, targetType, data.nextPageCursor, gamesIds)
end
else
warn(result)
getGamesIds(userId, cursor, gamesIds)
end
return gamesIds
end
local function GetGamepasses(userId, BoothUI, cursor, gamePasses)
cursor = cursor or ""
gamePasses = gamePasses or {}
local universeIds = getGamesIds(userId, "users")
for _, universeId in ipairs(universeIds) do
local requestUrl = gamePassesUrl:format(universeId, cursor)
local success, result = pcall(HttpService.GetAsync, HttpService, requestUrl)
if success and result then
local data = HttpService:JSONDecode(result)
for _, gamePass in ipairs(data.data) do
if gamePass.price and gamePass.IsForSale then
local Info = MarketPlaceService:GetProductInfo(gamePass.id, Enum.InfoType.GamePass)
table.insert(gamePasses, {
Description = Info.Description,
ImageId = Info.IconImageAssetId,
Name = gamePass.name,
Price = gamePass.price,
Id = gamePass.id,
Type = "Gamepass"
})
local Button = ServerStorage.Shared.donateFrame:Clone() -- Get the donation Frame
Button.TextButton.Text = gamePass.price.."$"
Button.PurchaseID.Value = gamePass.id
Button.Description.Value = Info.Description
Button.ImageID.Value = Info.IconImageAssetId --Property.Thumbnail.URL
Button.NameValue.Value = gamePass.name
Button.LayoutOrder = gamePass.price
_G.Products[gamePass.id] = {
["Creator"] = game:GetService("Players"):GetPlayerByUserId(userId),
["Price"] = gamePass.price,
["Type"] = "Gamepass"
}
Button.Parent = BoothUI
print(gamePass)
print(Info)
end
end
if data.nextPageCursor then
GetGamepasses(userId, BoothUI, data.nextPageCursor, gamePasses)
end
else
warn(result)
GetGamepasses(userId, BoothUI, cursor, gamePasses)
end
end
return gamePasses
end
But for some reason it just returns an empty array. Can anybody help me out here?