Skip to content

Instantly share code, notes, and snippets.

@codler
Created December 15, 2011 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codler/1481867 to your computer and use it in GitHub Desktop.
Save codler/1481867 to your computer and use it in GitHub Desktop.
Glesys API
<?php
$username = 'clXXXXX';
$password = '';
$base_url = 'https://api.glesys.com';
$param = '/server/list/format/json/';
$context = stream_context_create(array(
'http' => array(
'header' => "Authorization: Basic " . base64_encode("$username:$password")
)
));
$result = file_get_contents($base_url . $param, false, $context);
echo $result . PHP_EOL;
$json = json_decode($result, true);
if ($json && $json['response'] && $json['response']['status']['code'] == '200') {
echo $json['response']['servers'][0]['serverid'] . PHP_EOL;
} else {
echo 'Failed' . PHP_EOL;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment