<?php require_once __DIR__ . '/../../../libraries/autoload.php'; try { $maniaconnect = new \Maniaplanet\WebServices\ManiaConnect\Player('your_api_username', 'your_api_password'); $loginURL = $maniaconnect->getLoginURL('basic'); $player = $maniaconnect->getPlayer(); } catch (\Maniaplanet\WebServices\Exception $e) { // We ignore errors } if ($player) { // Player is logged in, do whatever you want echo $player->login; } else { // Player is not logged in, link or redirect to $loginURL printf('<a href="%s">Login</a>', htmlentities($loginURL)); }
require_once __DIR__ . '/../../../libraries/autoload.php'; define('API_USERNAME', 'api_username'); define('API_PASSWORD', 'api_password'); define('SCOPE', ''); try { $trackmania = new \Maniaplanet\WebServices\ManiaConnect\Player(API_USERNAME, API_PASSWORD); // URLs to log in and out $loginURL = $trackmania->getLoginURL(SCOPE); $logoutURL = $trackmania->getLogoutURL(); if (isset($_POST['logout'])) { $trackmania->logout(); header('Location: ' . $logoutURL); exit; } // Retrive player information. If the user is not logged in, it will return false $player = $trackmania->getPlayer(); } catch (\Maniaplanet\WebServices\Exception $e) { $player = null; // Uncomment to debug... //var_dump($e); } if (array_key_exists('HTTP_USER_AGENT', $_SERVER) && substr($_SERVER['HTTP_USER_AGENT'], 0, 11) == 'ManiaPlanet') { ?> <manialink version="0"> <timeout>0</timeout> <frame posn="0 25 0"> <label sizen="70 3" halign="center" text="$o$ff0ManiaConnect example" /> <?php if ($player) { ?>