API not working correctly

Website URL: https://xenixhub.xyz/api?ip=12.34.56.78

Hello, basically I made a simple “API” in PHP that gets a key binded to the IP provided in URL from the database. When you manually go to the website and you have an IP address that is in the database with a key, it will only display the key as “plain text” (content-type header).
However when I try to get the key using roblox lua:

local keyFromDb = game:HttpGet("https://xenixhub.xyz/api?ip=" . ip)

It returns the whole html code and a _test cookie?
But when I do the same thing in lua but for the IP using ipify’s API like so:

local ip = game:HttpGet("https://api.ipify.org")

It actually only returns and prints the IP and none of the HTML code.

Here is my whole code for the API (I removed the database information):

<?php
header('Content-Type: text/plain; charset=utf-8');

define('DB_SERVER', '');
define('DB_USERNAME', '');
define('DB_PASSWORD', '');
define('DB_DATABASE', '');

$sqlForRemove = "DELETE FROM userkeys WHERE expires < NOW() AND ip='$ip'";
mysqli_query($conn, $sqlForRemove);

$ip = $_GET["ip"];
$conn = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE);

$sql = "SELECT * FROM userkeys WHERE ip='$ip'";

$result = mysqli_query($conn, $sql);

$arr = $result->fetch_assoc();
$srvKey = $arr['userkey'];

echo $srvKey;
?>

It’s probably not working because InfinityFree is a website host, not an API host:

6 Likes

Wow that’s surprising, I never knew that. Any alternatives?

Also why the hell the free plan has unlimited bandwith and the “Super Premium” one has only 250GB? That doesn’t make snese to me…

Premium hosting. Or you can allow cookies and JavaScript in the application that is connecting to prevent it from getting blocked.

Where did you see that? Because that’s incorrect, and should be updated. Free hosting has less then 250GB, I can’t remember the exact number though…

1 Like

It’s on the homepage. If I’m not mistaken, the limit is 100GB/month.

2 Likes

Well if a business is so lazy to even update their premium plan information then I don’t think that’s a good choice…

The information about the free plan may be outdated, not the premium one.

Perhaps the “Free for Developers” list can help you: https://free-for.dev/

5 Likes

@ChrisPAR is right about that.

@nnaem12, here are the numbers for bandwidth:

Free Hosting: 100GB
Super Premium: 250GB
Ultimate Premium: Unmetered
VPS: 125GB

Information accurate as of Oct.26.2022. Information provided via ifastnet.com and infinityfree.net

3 Likes

Is there any way to pay with cryptocurrencies for a premium plan?

I am not sure, check on the payments page of ifastnet.com. You can also as support.ifastnet.com if that is a supported payment method.

4 Likes

Well I checked but there’s no way of paying using crypto, can support maybe help with that?

My guess is that it is not a supported method of payment, but you can always ask.

5 Likes

You can convert the crypto into USD or your currency and pay that way.

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.