Unknown Resource Type?

Maniaplanet public API, ManiaConnect system and the open source PHP SDK.

Moderator: NADEO

Post Reply
User avatar
danodude
Posts: 176
Joined: 01 Dec 2011, 12:25
Location: Western Australia

Unknown Resource Type?

Post 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:
User avatar
magnetik
Posts: 1673
Joined: 01 Feb 2012, 19:13
Location: Bordeaux
Contact:

Re: Unknown Resource Type?

Post 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.'"/>';
ManiaPlanet technical documentation portal (Dedicated, ManiaLink, ManiaScript, Titles...) -- contribute!
User avatar
danodude
Posts: 176
Joined: 01 Dec 2011, 12:25
Location: Western Australia

Re: Unknown Resource Type?

Post 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?
User avatar
steeffeen
Translator
Translator
Posts: 2463
Joined: 14 Oct 2012, 16:22
Location: Germany

Re: Unknown Resource Type?

Post 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
Last edited by steeffeen on 07 Apr 2014, 10:43, edited 1 time in total.
    Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

    ManiaControl, FancyManiaLinks
    User avatar
    danodude
    Posts: 176
    Joined: 01 Dec 2011, 12:25
    Location: Western Australia

    Re: Unknown Resource Type?

    Post 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.
    User avatar
    danodude
    Posts: 176
    Joined: 01 Dec 2011, 12:25
    Location: Western Australia

    Re: Unknown Resource Type?

    Post by danodude »

    Small bump :)
    User avatar
    danodude
    Posts: 176
    Joined: 01 Dec 2011, 12:25
    Location: Western Australia

    Re: Unknown Resource Type?

    Post 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
    Post Reply

    Return to “Maniaplanet Web Services”

    Who is online

    Users browsing this forum: No registered users and 1 guest