How do I do GET requests with php?

Sorry if I sound super dumb, but I’m trying to get into web development so it can go alongside with my normal game dev. One thing I’m trying to accomplish is a proxy with roblox httpservice since you can’t do requests to with roblox’s httpservice.

here’s my php code:

    $gid = $_GET["groupid"];
    echo $gid;
    $info = http_get("" . $gid);
    echo $info;

I print the groupid I sent in the get request as a test and it works, but I want test and mess around with roblox’s web apis, but how do I do a get request with php?

1 Like


I already have the lua side setup. I just want to send a get request to my web server(which is working fine) and then use my web server to send a get request to a roblox api site so that my roblox get request gets the information from the roblox web api site.

PHP seems pretty hard to wrap ones head around. There may be a way to get Apache to act as a proxy, but I’m pretty sure unless you use a library with PHP you’re going to have to work with sockets and stuff.

If you would be willing to switch to nodejs then here is some code I’ve written as an example for someone else with expressjs. If you have any questions about using nodejs to host a web server then shoot me a pm.

Then it depends on which library you’re using.

How do I know what library I’m using?

If you still want to use PHP and are just looking to send a get request then maybe try this.

1 Like

Well until you’ve picked a library to use, you’re not using any.

How do I use a library for this or add one?

You’d have to pick one first. I haven’t done PHP programming so I’m not familiar with what’s offered. Search around until you find one that seems to fit your needs or that has good documentation or learning material. If you’re new to programming or new to PHP perhaps check out some basic tutorials first.

Simple as this
echo file_get_contents(url);

Also here is something I wrote in node.js if you’d like to learn using Node.

1 Like

You never actually put a protocol in.

$info = http_get("" . $gid);


you can always try a CORS proxy instead, if it’s just a proxy you’re after:


local request = require(
local proxy ={
    baseUrl = '',
    json = true

    url = ''
    --> "RobloxHunks"

… that may not be correct. typed on mobile

You may want to go with Node.JS, it tends to be simpler.
However, if you are set on PHP, I believe the reason your code isn’t working is because http_get is no longer default in PHP.

You can go with “file_get_contents” as stated above, however three things to note about that.

  1. It cannot set any headers, method, body, etc.
  2. It is disabled on some php installations for security reasons. It can be re-enabled, however.
  3. You cannot get response information (headers, status code, etc)

You could also go with cURL, which is the best choice should you keep doing web development.
cURL allows you to set tons of parameters, as shown here, that change the request. For example, the post body, the request method, etc.
A simple cURL request will look something like that:

        // initiate curl request
        $cur = curl_init();

        curl_setopt($cur, CURLOPT_URL, ""); // set url for request
        curl_setopt($cur, CURLOPT_RETURNTRANSFER, 1); // return response as $output

        $output = curl_exec($cur);

$output would be the equivalent to your $info
This code doesn’t perform any checks to make sure the request succeeded, or that it’s status code is correct.
You can learn about doing that on the php wiki.