I've already made a mess of the code, spread over a bunch of files.

But even when I run tweaked versions of the example code below it won't work.
Examplecode taken from
http://forum.funtrackers.net/showthread ... niaconnect
Code: Select all
<?php
// Change these values to match your MPWS user
define('MPWS_USER', XXXXXXXXX');
define('MPWS_PASS', 'XXXXXXXXX');
define('MPWS_SCOPE', 'basic');
// Include the MPWS files
require('libraries/autoload.php');
try {
// Try to retrieve the data of the player
$mpwsPlayer = new \Maniaplanet\WebServices\ManiaConnect\Player(MPWS_USER, MPWS_PASS);
$player = $mpwsPlayer->getPlayer();
if (!$player) {
// If $player equals false, we need the player to grant access to his or her data,
// so we need to print the LoginURL
$loginURL = htmlspecialchars($mpwsPlayer->getLoginURL(MPWS_SCOPE));
$label = '<label style="CardButtonMedium" text="Authentificate" manialink="'.$loginURL.'" />';
} else {
// If $player is not false, the player allowed accessing his or her data,
// so we are able to e.g. print the Nickname
$nickname = htmlspecialchars($player->nickname);
$label = '<label sizen="100 5" halign="center" text="Your Nickname: '.$nickname.'" />';
}
} catch (\Maniaplanet\WebServices\Exception $e) {
// Accessing ManiaConnect or the WebServices in general has failed.
// In this case, we simply print the error message.
$message = htmlspecialchars("[{$e->getHTTPStatusCode()} {$e->getHTTPStatusMessage()}] {$e->getMessage()}", ENT_QUOTES, 'UTF-8');
$label = '<label sizen="100 5" halign="center" text="Exception: '.$message.'" />';
}
// Output the ManiaLink
header('Content-Type: text/xml; charset=utf-8');
echo <<<EOT
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<manialink version="1">
<timeout>0</timeout>
{$label}
</manialink>
EOT;
?>
This works just fine and in terms of output xml without aouthentification it gives me
Code: Select all
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<manialink version="1">
<timeout>0</timeout>
<label style="CardButtonMedium" text="Authentificate" manialink="https://ws.maniaplanet.com/oauth2/authorize/?client_id=munglo%7Cbazinga&redirect_uri=http%3A%2F%2Fskynet-irc.com%2Fml%2Fbazinga.php&scope=basic&response_type=code" />
</manialink>
But then if I try to change the button for authentification to a redirect <goto> like say..
Code: Select all
<?php
// Change these values to match your MPWS user
define('MPWS_USER', 'XXXXXXXXX');
define('MPWS_PASS', 'XXXXXXXXX');
define('MPWS_SCOPE', 'basic');
// Include the MPWS files
require('libraries/autoload.php');
try {
// Try to retrieve the data of the player
$mpwsPlayer = new \Maniaplanet\WebServices\ManiaConnect\Player(MPWS_USER, MPWS_PASS);
$player = $mpwsPlayer->getPlayer();
if (!$player) {
// If $player equals false, we need the player to grant access to his or her data,
// so we need to print the LoginURL
$loginURL = htmlspecialchars($mpwsPlayer->getLoginURL(MPWS_SCOPE));
//$label = '<label style="CardButtonMedium" text="Authentificate" manialink="'.$loginURL.'" />';
$label = '<goto><link>'.$loginURL.'</link></goto>';
// Output the ManiaLink redirectLogin
header('Content-Type: text/xml; charset=utf-8');
echo <<<EOT
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<manialink version="1">
<timeout>0</timeout>
{$label}
</manialink>
EOT;
exit;
}
$player = $mpwsPlayer->getPlayer();
if ($player) {
// If $player is not false, the player allowed accessing his or her data,
// so we are able to e.g. print the Nickname
$nickname = htmlspecialchars($player->nickname);
$label = '<label sizen="100 5" halign="center" text="Your Nickname: '.$nickname.'" />';
}
} catch (\Maniaplanet\WebServices\Exception $e) {
// Accessing ManiaConnect or the WebServices in general has failed.
// In this case, we simply print the error message.
$message = htmlspecialchars("[{$e->getHTTPStatusCode()} {$e->getHTTPStatusMessage()}] {$e->getMessage()}", ENT_QUOTES, 'UTF-8');
$label = '<label sizen="100 5" halign="center" text="Exception: '.$message.'" />';
}
// Output the ManiaLink
header('Content-Type: text/xml; charset=utf-8');
echo <<<EOT
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<manialink version="1">
<timeout>0</timeout>
{$label}
</manialink>
EOT;
?>
Then it outputs in xml
Code: Select all
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<manialink version="1">
<timeout>0</timeout>
<goto><link>https://ws.maniaplanet.com/oauth2/authorize/?client_id=munglo%7Cbazinga&redirect_uri=http%3A%2F%2Fskynet-irc.com%2Fml%2Fbazinga.php&scope=basic&response_type=code</link></goto>
</manialink>
Which to me looks ok but still ManiaPlanet will not, get page->redirect->show nickname, as it did when using the button.
$player is still empty and in ManiaPlanet an empty page is shown.
Overall and as far as I can tell it is sticking to UTF-8 all the way.
Only thing that strikes me is the "redirect_uri" in the loginURL.

Shouldn't it rather be redirect_url? But since I haven made that part and it worked with the button I guess it's ok as is.
I hope I'm just stupid as usual and someone more experienced can see where I have gone wrong. That's how it usually goes.
