MojangAPI icon indicating copy to clipboard operation
MojangAPI copied to clipboard

Cannot find my user

Open KendaFR opened this issue 3 years ago • 2 comments

Hello,

I downloaded the api file to make an admin panel of my server, but impossible to retrieve information from it. I did import my file, but 0 results from any functions.

Can you help me ?

@section('content') <?php require app_path().'/mojang-api.class.php'; ?> <div class="content"> <?php $name = MojangAPI::getUsername('6ce86bff-695f-4a5b-b6c5-7e924975f74b'); echo 'Name: <b>' . $name . '</b><br>'; ?> </div> @endsection image

KendaFR avatar Jan 21 '22 20:01 KendaFR

I just tested it, and this does work for me:

$ php -a
Interactive shell

php > require './mojang-api.class.php';
php > $name = MojangAPI::getUsername('6ce86bff-695f-4a5b-b6c5-7e924975f74b');
php > echo 'Name: <b>' . $name . '</b><br>';
Name: <b>Kenda_</b><br>

Maybe it's your host? I heard some hosting services like OVH are often blocked by Mojang's API, due to too many requests made by the same host.

MineTheCube avatar Mar 09 '22 18:03 MineTheCube

Me: Oh I'll just quickly update my Minecraft API since they broke it last year. Also me: 2 hours later

So after looking into why this wasn't working, something is going wrong with the CURL's SSL check on Mojangs domain. I have no idea why. But disabling the curl opt CURLOPT_SSL_VERIFYPEER got this working again on line 722. Not ideal. But its a minecraft API for my local MC server, I'm hardly worried about the authenticity of the mojang API.

Some further information.

Dumping out the curl error with: var_dump(curl_error($ch)); shows this: Warning: curl_error(): supplied resource is not a valid cURL handle resource in D:\my-path-to-project\minethecube.mc-api\mojang-api.class.php on line 728

Commenting out line 726 and preventing the curl from closing then changes that error to this: SSL certificate problem: unable to get local issuer certificate

Again, I don't understand why the SSL cert would be working in a browser and not in a cURL request. But disabling the SSL verification works for me, I'll leave my contribution at that.

Peace.

dfeneck avatar Mar 08 '23 08:03 dfeneck