local ID = script.ScriptId.Value
local Url = "https://script.google.com/macros/s/" .. ID .. "/exec"
local HttpService = game:GetService("HttpService")
local HttpProxy = {}
function JSONDecode(JSON)
local JSONTable = {}
pcall(function ()
JSONTable = HttpService:JSONDecode(JSON)
end)
return JSONTable
end
function HttpProxy:GetAsync(Link)
local JSON = HttpService:GetAsync(Url .. "?q="..game.HttpService:UrlEncode(Link))
local Result = JSONDecode(JSON)
if Result.result == "success" then
return Result.response
else
warn(tostring(Link).." failed to fetch because "..tostring(Result.error))
return
end
end
return HttpProxy
And here is the code I am using to retrieve the player’s favorite games:
local HttpService = game:GetService("HttpService")
local HttpProxy = require(game.ServerScriptService:WaitForChild("HttpProxy"))
local BaseUrl = "https://www.roblox.com/users/favorites/list-json?assetTypeId=9&itemsPerPage=400&pageNumber=1&userId=7597220565"
HttpService:JSONDecode(HttpProxy:GetAsync(BaseUrl))
For some reason, it is giving me two errors. The top error is outputted by the proxy and the bottom one is by my request code.
I have tampered with the code to hell and back, and I do not seem to know what is wrong. I am very new to using proxies, and from what I can tell, it is the requesting code that is broken and not the proxy, though I still don’t know what exactly is wrong with it.
The API you’re using is deprecated, use the following API instead: https://catalog.roblox.com/v1/favorites/users/{userId}/favorites/{categoryId}/assets?limit=100
Also instead of pages you will have to work with cursors.
I am unaware of how cursors work. Could you explain it or direct me to somewhere where I can read up on how they work? Also, with the parts in curly brackets, do I just put the proper number in and nothing else, or does something else go there like “userId=7597220565” or something?
For the brackets, you just put in the numbers. So replace {userId} with the desired user id.
Now for cursors it really depends on the endpoint, but for this just pass the cursor={cursor} parameter in the url. Start with an empty string as a cursor to fetch the first page( so cursor= or don’t set the parameter) it will return a json encoded table with a value named nextPageCursor, store that in a variable, and when you want to fetch the next page put it inside the cursor={nextPageCursor} url parameter. When the returned result doesn’t have a nextPageCursor (basically when it is null/nil) it means that there are no more pages to fetch.
Alright, I understand. How would I properly insert the cursor into the URL (Do I just put a slash and then the cursor with the number or something else)? I am not used to this new API, and this still doesn’t explain why the error persists.
Update: I have gotten a functional url but it does not seem to supply me with anything useful, and attempting to edit it to do so gives the original error
local BaseUrl = "https://inventory.roblox.com/v1/users/7597220565/categories/favorites"
How do I edit this to give me the games within the favorites page?