Page 1 of 1

Unknown Resource Type?

Posted: 03 Apr 2014, 07:17
by danodude
Hi guys :)

I've just started using ManiaConnect, and have successfully created a simple script to return my login when I login through the Player Page (HTML + PHP).

I have a problem when I try to use the same code in a Manialink. I keep getting Unknown Resource Type errors, and I was wondering what they mean, and what I have done wrong in my code.

Here is the working HTML + PHP script:

Code: Select all

<?php

require_once 'libraries/autoload.php';

define('USERNAME', 'MAH USHURNAHM');
define('PASSWORD', 'MAH PASSWHURD');
define('SCOPE', 'basic buddies');

$maniaconnect = new \Maniaplanet\WebServices\ManiaConnect\Player(USERNAME, PASSWORD);
$player = $maniaconnect->getPlayer();

// If the player is connected/logged in, return player's login.
if($player)
{
        $login = $player->login;
}
// If the player is not connected/logged in, move them into the player page to sign in.
else
{
        $loginURL = $maniaconnect->getLoginURL(SCOPE);
        echo '<a href="'.$loginURL.'">Login with your Maniaplanet account</a>';
}

?>

<html>
	<head>
		<title>Return Login</title>
	</head>
	
	<body>
		<?php echo $login; ?>
	</body>
</html>
And here is the XML + PHP script that doesn't seem to work:

Code: Select all

<?php

require_once 'libraries/autoload.php';

define('USERNAME', 'MAH USHURNAHM');
define('PASSWORD', 'MAH PASSWHURD');
define('SCOPE', 'basic buddies');

$maniaconnect = new \Maniaplanet\WebServices\ManiaConnect\Player(USERNAME, PASSWORD);
$player = $maniaconnect->getPlayer();

// If the player is connected/logged in, return player's login.
if($player)
{
        //echo $player->login;
	echo '<manialink>';
	echo '<frame posn="0 0 0">';
	echo '<label posn="0 0 0" scale="1.5" text="'echo $player->login'"/>';
	echo '</frame>';
	echo '</manialink>';
}
// If the player is not connected/logged in, move them into the player page to sign in.
else
{
        $loginURL = $maniaconnect->getLoginURL(SCOPE);
	
        //echo '<a href="'.$loginURL.'">Login with your Maniaplanet account</a>';
	echo '<manialink>';
	echo '<frame posn="0 0 0">';
	echo '<label posn="0 0 0" scale="1.5" text="Please sign in..."/>';
	echo '<label posn="0 -10 0" style="CardButtonMedium" text="Sign In" manialink="'$loginURL'"/>';
	echo '</frame>';
	echo '</manialink>';
}

?>
I think my problem is that I don't understand how I'm supposed redirect the player so he can login through the Manialink. Am I supposed to open up a browser window with the actual Player Page login screen, or is there a way to do that in-game?

Thanks guys :D Sorry if I get annoying asking so many questions :mrgreen:

Re: Unknown Resource Type?

Posted: 03 Apr 2014, 07:50
by magnetik
From what I see, you have an error here:

Code: Select all

echo '<label posn="0 0 0" scale="1.5" text="'echo $player->login'"/>';
to concatenate a string and a variable, you have to do :

Code: Select all

echo 'blabla'.$myVariable.'blabla'.$anotherOne.'end';
so for your example :

Code: Select all

echo '<label posn="0 0 0" scale="1.5" text="'.$player->login.'"/>';

Re: Unknown Resource Type?

Posted: 03 Apr 2014, 08:26
by danodude
Duh, that was stupid of me :lol: Thanks.

That fixed the unknown error, but I now get that dialog box that says 'Oops an unfortunate error has occured, please try again later".

Why does this happen?

Re: Unknown Resource Type?

Posted: 03 Apr 2014, 10:47
by steeffeen
just wanted to note: 'unknown resource type' basically means that maniaplanet wasn't able to decode the xml text, so usually that comes from the fact that its syntax is broken in some way

about 'unfortunate error' i would guess that it's caused by the maniaconnect api
the error occurs after clicking the "log in" label, right?
please double check your username + password

//Edit: fixed typo

Re: Unknown Resource Type?

Posted: 03 Apr 2014, 10:56
by danodude
Yes the error occurs after I click the 'Sign In' button.

My password & username are correct, because the PHP + HTML version works fine with the same user/password.

Re: Unknown Resource Type?

Posted: 07 Apr 2014, 10:29
by danodude
Small bump :)

Re: Unknown Resource Type?

Posted: 09 Apr 2014, 06:13
by danodude
I found out what was wrong :D

I needed to put 'htmlspecialchars()' around this line:

Code: Select all

$loginURL = $maniaconnect->getLoginURL(SCOPE);
So its like this:

Code: Select all

$loginURL = htmlspecialchars($maniaconnect->getLoginURL(SCOPE));
Just thought I'd say that in case other newbies have the same problem as me :P