Skip to content

Instantly share code, notes, and snippets.

@sdieunidou
Last active November 29, 2018 12:13
Show Gist options
  • Save sdieunidou/7bbe2426ed73ba654d52 to your computer and use it in GitHub Desktop.
Save sdieunidou/7bbe2426ed73ba654d52 to your computer and use it in GitHub Desktop.
<?php
// READ: https://mtxserv.com/forums/threads/api-game-viewer.295/
// Example usage of API Game Viewer (mtxserv.com)
$urlToken = 'https://mtxserv.com/oauth/v2/token?';
$urlViewer = 'https://mtxserv.com/api/v1/viewers/game?';
$query = array(
'grant_type' => 'https://mtxserv.com/grants/api_key',
'client_id' => '', // A Editer
'client_secret' => '', // A Editer
'api_key' => '' // A Editer
);
$response = file_get_contents($urlToken . http_build_query($query));
if (false === $response) {
die('Identification incorrecte');
}
$response = json_decode($response);
$accessToken = $response->access_token;
// get viewer
$query = array(
'access_token' => $accessToken,
'ip' => 'your gameserver_ip', // A Editer
'port' => 27030, // A Editer
'type' => 'day-of-defeat-source' // A Editer ; list: https://mtxserv.com/forums/threads/api-game-viewer.295/
);
$response = file_get_contents($urlViewer . http_build_query($query));
if (false === $response) {
die('Une erreur est survenue');
}
$response = json_decode($response);
var_dump($response);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment