Skip to content

Instantly share code, notes, and snippets.

@stevenlr
Created February 19, 2012 17:08
Show Gist options
  • Save stevenlr/1864667 to your computer and use it in GitHub Desktop.
Save stevenlr/1864667 to your computer and use it in GitHub Desktop.
Récupérer la liste des connectés à Orasia
<?php
/*
* Retourne un tableau JSON : ["player 1", "player 2", ...]
*/
function get_orasia() {
$url = "http://188.165.212.56/mapviewer/serveur2/world/chattercraft/chatter.php";
$data = file_get_contents($url);
$xml = simplexml_load_string(str_replace('<?xml version="1.0">', '<?xml version="1.0" ?>', $data));
$list = $xml->mcserver->playerlist->player;
$arr = array();
foreach($list as $user) {
$arr[] = '"'.$user.'"';
}
$data = "[".implode(", ", $arr)."]";
return $data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment