Hello there, I am making a Roblox catalog browser for a new version of my most popular game and have begun the foundation pretty well but have hit a roadblock. I mainly just want to know if/how I can send a string from my game to my proxy. I am completely new to proxys but here is what I have so far:
2.) Created a script in game that calls HttpService:JSONDecode(HttpService:GetAsync(myURL)) to the proxy which returns a list of the accessories and creates a button for each one
3.) Created a script to wear the items when the accessory’s button is clicked
Everything works great so far, but I have no idea how (or if) I can send a string to the proxy from the game in order to search for different keywords.
I would like to be able to get a string from the player via a gui textbox (which I know how to do) but then send the players keywords to the proxy, I just have no clue how to pass info to the proxy IF it is possible. The full proxy script is shown below, the // are commented out lines that do not run, like the - - in roblox lua. I forget why I removed the lines, may not have been working.
Specifically, it adds a Subcategory parameter. These subcategories are arbitrary numbers (Hat = 9, Hair = 20, Face = 21, etc) so you’ll have to pass this number to this proxy endpoint via your own GET parameter. You can do this by adding &AccessoryType=somenumberhere to the end of your proxy server’s URL. Your URL on line 10 already has this parameter in the middle, so you will be using that.
I believe this article should help you with grabbing AccessoryType’s value. I really only have experience with Express.js so I’m not 100% sure this will work. It’s from nodejs.org and since you’re using their built-in HTTP module, I would count on it.
The code you would use would probably be something like the following:
const url = require('url'); // Add this to the top of your script
...
http.createServer((req, res) => { // This is your line 8
const queryObject = url.parse(req.url, true).query;
let accessoryType = queryObject.AccessoryType;
...
// Substitute the accessoryType variable for your hard-coded "9" on line 10
You should also make sure you’re using ?AccessoryType= in your script’s URL as the first GET parameter should always start with a ?. Proceeding parameters should start with &.
It works! Thank you so much, i tried the +'s last night but didn’t put a space so i was getting an error, then like you said i also had to swap out the & for a ? in my Roblox script. Now everything is running perfectly, I very much appreciate the help!
While I have your expertise, is there any possibility you would know how I would be able to tell if there are more pages than the first one returned? I have never used nextPageCursor so I have no clue how I should go about this. This is a clip of my Roblox script that deals with the catalog results…
local results = CatalogSearchResults.data
local function DoIt()
for i=1, #results do
local newButton = script.Parent.GearFrame.ImageButton:Clone()
newButton.Name = results[i].id
newButton.Image = "https://www.roblox.com/asset-thumbnail/image?assetId="..(results[i].id).."&width=420&height=420&format=png"
newButton.Parent = script.Parent.GearFrame
local pageObject = results[i].nextPageCursor