Last active
November 29, 2018 12:13
-
-
Save sdieunidou/7bbe2426ed73ba654d52 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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