API Ideas

Status
This thread has been locked.

Christopher

Floating around
Supreme
Feedback score
8
Posts
2,048
Reactions
1,120
Resources
0
smh use cURL. The content contained " " which you didn't strip with strip_tags

Code:
$ch = curl_init('https://api.mcuuid.com/json/server/test.blaa.net:25589');
curl_setopt_array($ch, array(
    CURLOPT_SSL_VERIFYPEER => 0,
    CURLOPT_SSL_VERIFYHOST => 0,
    CURLOPT_RETURNTRANSFER => 1
));
$res = curl_exec($ch);

if (!$res) {
    die('Could not connect.');
}

var_dump(json_decode(strip_tags(str_replace(' ', '', $res))));

Incrementing
Please don't output your JSON with html tags & nbsp's...

Code:
$data = array(
    'key' => 'value'
);

header('Content-Type: application/json');
echo json_encode($data, JSON_PRETTY_PRINT);

More Suggestions:
  • Use "ServerTokens Prod" to avoid showing your server version
  • Use nginx, it's so much better than apache
  • (personal preference: centos over ubuntu ;))
  • Invalid API endpoints should return a JSON response, not a 404 document
Thanks!

Btw: You forgot the " ,true " in the json_decode.
 

Christopher

Floating around
Supreme
Feedback score
8
Posts
2,048
Reactions
1,120
Resources
0
You only need the true if you want it in the format of an array. I'm perfectly fine with doing $object->value.
Yea, I wanted it in array form,

Thanks again!
 

Incrementing

gian.sh
Banned
Feedback score
16
Posts
246
Reactions
146
Resources
0
smh use cURL. The content contained " " which you didn't strip with strip_tags

Code:
$ch = curl_init('https://api.mcuuid.com/json/server/test.blaa.net:25589');
curl_setopt_array($ch, array(
    CURLOPT_SSL_VERIFYPEER => 0,
    CURLOPT_SSL_VERIFYHOST => 0,
    CURLOPT_RETURNTRANSFER => 1
));
$res = curl_exec($ch);

if (!$res) {
    die('Could not connect.');
}

var_dump(json_decode(strip_tags(str_replace(' ', '', $res))));

Incrementing
Please don't output your JSON with html tags & nbsp's...

Code:
$data = array(
    'key' => 'value'
);

header('Content-Type: application/json');
echo json_encode($data, JSON_PRETTY_PRINT);

More Suggestions:
  • Use "ServerTokens Prod" to avoid showing your server version
  • Use nginx, it's so much better than apache
  • (personal preference: centos over ubuntu ;))
  • Invalid API endpoints should return a JSON response, not a 404 document
Right, I've made a few changes to how the JSON is output.
Well... I say a few changes... I made it output correctly.

Before (oh god... I'm going get roasted) I was writing the JSON out as a string in php and echoing that to the user. Now (I'm doing it correctly) an array is created and that is echoed with json_encode().

Example of output:
PHP:
    $return = array(
        "success" => "false",
        "server" => $domain,
        "port" => $port,
        "error" => "Port out of range",
        "received_at" => round($start * 1000),
        "replied_at" => round(microtime(true) * 1000),
        "request_count" => $db->get_rate(),
        "max_requests" => "200",
    );
    die(json_encode($return));

I've also created a test.php file to check that this works (I'll remove it at some point).
PHP:
<?php
$ch = curl_init('https://api.mcuuid.com/json/server/mc.hypixel.net');
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$res = curl_exec($ch);

if (!$res) {
    die('Could not connect.');
}

$json = json_decode($res);
foreach ($json as $output) {
    echo $output . "<br>";
}
HTML:
true
mc.hypixel.net
25565
32ms
N/A
N/A
N/A
N/A
N/A
N/A
1475045030760
1475045030830
7
200
[DOUBLEPOST=1475046730][/DOUBLEPOST]Note: The uuid->name API isn't yet correctly formatted but I have to catch a bus :tup:.
All (json) APIs should now output correctly.
 
Last edited:
Banned forever. Reason: Scamming (https://builtbybit.com/threads/incrementing-scam-report.598498/)
Status
This thread has been locked.
Top