minethecube / mojangapi Goto Github PK
View Code? Open in Web Editor NEWA easy-to-use PHP class for accessing official Mojang's API
License: GNU General Public License v3.0
A easy-to-use PHP class for accessing official Mojang's API
License: GNU General Public License v3.0
Hey! I am trying to get hypixel's players online on my site but it always says that this server is offline :(
<?php require 'MojangAPI/mojang-api.class.php'; $query = MojangAPI::query('eu.hypixel.net', 25565); if ($query) echo '<a href="#" style="color: green;">Hypixel online' . $query['players'] . '/' . $query['maxplayers']. '</a>'; else echo '<a href="#" style="color: red;">Hypixel is offline.</a>' ?>
P.S. your example won't work too.
Using your class, I can check server status and icon. However I cannot seem to get any UUIDs, usernames or such from players. Have I done something wrong or is it somehow outdated or not working? I'd love to use your class if it ends up working for me, due to its ease of use compared to what I have to do otherwise.
In the code I write my data from my account Mojang:
// Require API
require 'mojang-api.class.php';
$result = MojangAPI::authenticate('[email protected]', 'mypassword');
if ($result) {
echo 'Welcome ' . $result['name'] . ', your UUID is: ' . $result['id'];
} else {
echo 'Sorry, authentication failed.. :(';
}
And the result shows the error message. (Here I deleted my personal data for anyone to see, but in the code I wrote it correctly)
[REDACTED]
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
It'd be great if this can be used under FLOSS license (e.g. MIT or Apache 2.0).
In mojang-api.class.php line 178:
The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence
A priori vous êtes français moi aussi, ca sera plus simple :) C'est dommage je suis allé sur votre serveur vous n'y étiez pas :(
Bref j'ai trouver un script de test que vous avez partagé dans une autre issue, et j'ai un problème un peu différent :s
<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
$url = 'https://api.mojang.com/users/profiles/minecraft/MTC';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
$output = curl_exec($ch);
var_dump($output);
var_dump(curl_error($ch), curl_errno($ch));
curl_close($ch);
Le script retourne tout çà :
string(555) "
ERROR
The request could not be satisfied.
Request blocked.
Generated by cloudfront (CloudFront)
Request ID: CjhzWljAre53I1sRh6vNcl92Axbjfi8droxGU_D8qXgzzyuQBTw_eA==
" string(0) "" int(0)
J'héberge moi même le site web sur un serveur dedié.
Il tourne sur Debian 8.
J'ai installer l’extension php5-curl.
Sa fait une bonne journée que je cherche un moyen pour résoudre ce problème mais rien a faire.
J'ai essayé un file_get_contents(); qui du-coup marche très bien en local, mais sur le site rien a faire çà ne marche pas. Puis plein d'autres petites solutions sur différents forum, vous m’enlèverez une épine du pied si vous me trouvez le problème ;)
Cordialement,
DURAND LUCAS.
I am getting false results on a server that I tried pinging. The webpage just returns false. It is the Example.php code that I changed the server adress in. Please help.
Can you add composer file and namespace ?
According to the Mojang API wiki, the status API has been removed, so it is better to remove it from this repo to avoid confusion.
Ever heard of namespacing? Jesus, this code reminds me of 2005
Does your API still work? Can't get it to do so.
This is my code:
<?php
// Require API
require 'mojangApi.php';
// Get UUID from username
$uuid = MojangAPI::getUuid('MTC');
echo 'UUID: <b>' . $uuid . '</b><br>';
// Get his name history
$history = MojangAPI::getNameHistory($uuid);
echo 'First username: <b>'.reset($history)['name'].'</b><br>';
// Print player's head
$img = '<img src="' . MojangAPI::embedImage(MojangAPI::getPlayerHead($uuid)) . '" alt="Head of MTC">';
echo 'Skin:<br>' . $img . '<br>';
?>
This is how the website looks like when it's loaded:
I read that warning but when I do:
if(MojangAPI::getUuid('Player')
it always returns false.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.