Test SDK page + Source code

Trackmania Forever public API and its open source PHP SDK.

Moderator: NADEO

Post Reply
tmrapidserv
Posts: 43
Joined: 22 May 2011, 20:45

Test SDK page + Source code

Post by tmrapidserv »

Hi,

I present to you my SDK test page, with a password (only beta-testers and Nadeo team).
I censored some parts, no leak ;)

The URL : http://test-sdk.tmrapidserv.fr.nf/
The password : UNG9CbM=Ij*l~kpw-i2uy{ha 3YhMNd5
The source code (can an admin or moderator make a spoiler pls ?) of tests.php :

Code: Select all

<?php 

	if (isset($_POST['password']) AND $_POST['password'] == "***********") // If pass is OK
	{
	if(!isset($_POST['login']))
{
?>
<p>Welcome to the TrackMania WS SDK test homepage.</p>
<p>Type a login for test :</p>
<form id="form1" name="form1" method="post" action="">
  <label for="login">Login :</label>
  <input type="text" name="login" id="login" /><br />
  <input type="submit" name="ok" id="ok" value="OK" />
  <input type="hidden" name="password" value="<?php echo $_POST['password']; ?>" />
</form>
<?php
}
else
{
	try
	{
		$login = htmlspecialchars($_POST['login']);
		require_once '*****/trackmania-ws-sdk/src/trackmania-ws.php';
		require_once '*****/trackmania-ws-sdk/color-parser/classes/tmfcolorparser.inc.php';
		$cp = new TMFColorParser();
		$cp->alwaysDrawFontShadows = true;
		$tmPlayers = new TrackMania_Players('**NAME-USERAPI**', '**PASS-USERAPI**');
		$hugo_hd = $tmPlayers->get($login);
		$hugo_hd_rank_online1 = $tmPlayers->getMultiplayerRanking($login);
		if($hugo_hd->united == 1) { $hugo_hd_united = "United"; } else { $hugo_hd_united = "Nations"; }
	}
	
	catch(TrackMania_Exception $e)
	{
		printf("HTTP Response: %d %s\n", $e->getHTTPStatusCode(), $e->getHTTPStatusMessage());
		printf("API Response: %s (%d)\n", $e->getMessage(), $e->getCode());
	}
	
	$cp = new TMFColorParser();
	$cp->alwaysDrawFontShadows = true;
	$tmPlayers = new TrackMania_Players('**NOMUSER**', '**PASSUSER**');
	$hugo_hd = $tmPlayers->get($login);
	$hugo_hd_rank_online1 = $tmPlayers->getMultiplayerRanking($login);
	if($hugo_hd->united == 1) { $hugo_hd_united = "United"; } else { $hugo_hd_united = "Nations"; }
	echo '<span>Login :</span> '.$hugo_hd->login.', nickname : '.$cp->toHTML($hugo_hd->nickname).', this player has got '.$hugo_hd_united.', his location is '.$hugo_hd->path.', he is '.$hugo_hd_rank_online1->ranks['0']->rank.' in the world in multiplayer, he\'s got '.$hugo_hd_rank_online1->points.' LP.<br />';
	?>
	<p>Welcome to the TrackMania WS SDK test homepage.</p>
<p>Type a login for test :</p>
<form id="form1" name="form1" method="post" action="">
  <label for="login">Login :</label>
  <input type="text" name="login" id="login" /><br />
  <input type="submit" name="ok" id="ok" value="OK" />
  <input type="hidden" name="password" value="<?php echo $_POST['password']; ?>" />
</form>
<br /><br />
$tmPlayers->get :<br />
<?php
print_r($hugo_hd);
?>
<br />$tmPlayers->getMultiplayerRanking :<br />
<?php
print_r($hugo_hd_rank_online1);
?>
<?php
}
}
else
{
?>

<p>This isn't the good password !</p>
<?php
}
?>
This page use the SDK v0.6.

Thank you for testing it and please comment it !

Note : If the page not works. Start CMD and type on the console ipconfig /flushdns
After that, it would work.
Note 2 : sorry for my bad english, i'm french :P


The TMRapidServ team.
User avatar
Jojo_44
Posts: 485
Joined: 12 Jul 2010, 15:58
Location: Germany->Bavaria
Contact:

Re: Test SDK page + Source code

Post by Jojo_44 »

Hi,

I think every beta tester have done a site like yours. And btw you don´t need the colorparser because there´s a method to get the nickname html styled:
function getNicknameHTML($login)
have a good weekend, Jojo
Image
my english sounds very unfriendly but it isn´t ;)
tmrapidserv
Posts: 43
Joined: 22 May 2011, 20:45

Re: Test SDK page + Source code

Post by tmrapidserv »

Yes but I like this color-parser :lol:
Post Reply

Return to “Trackmania Forever Web Services”

Who is online

Users browsing this forum: No registered users and 2 guests