getPlayer() with old token

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

Moderator: NADEO

Post Reply
Posts: 316
Joined: 12 Jul 2012, 03:37

getPlayer() with old token

Post by MuNgLo » 15 May 2013, 11:10

What does maniaconnect getplayer() returns if you use an old token?
It just says "If an access token is not found, it will return false".

or how do you actually check that the token is valid and if invalid request a new one.

Posts: 316
Joined: 12 Jul 2012, 03:37

Re: getPlayer() with old token

Post by MuNgLo » 15 May 2013, 13:14

Seems it is actually after getplayer() when I try to getTeams() something happens.

getTeams() and getContracts() both end up making my code fail.

Even this example makes the manialink blank after this code is run.

Code: Select all

$teams = $mpwsPlayer->getContracts();
The player object seems to be the same regardless of how old token or what not. But after 1hour or so the getTeams/getContracts fail somehow. As soon as I comment out those I am just fine again and all of the manialinks showsup again.

Posts: 1041
Joined: 15 Jun 2010, 15:46

Re: getPlayer() with old token

Post by The_Big_Boo » 15 May 2013, 15:45

The default persistance system used in the SDK is the session (you can make your own persistance but I don't think anybody is doing it). As you probably knows, a session expires by default after a few hours (4 I think) without any user request, which will be longer than the token validity anyway. So, after an hour, you end up with an invalid token in the session and any method will fail. However, there is a single exception to this, which is getPlayer(): it's result is also stored in the session (or any persistance) so it won't fail.

At the moment, the simple solution is to call Maniaplanet\WebServices\ManiaConnect\Client::logout() which will actually destroy the session to start a whole new one but it can be unfortunate sometimes.

Maybe one day there will be a better solution. I remembered looking into it for the Competition Manager and talking with gouxim about it (because it happens a lot for players) but it's not that easy to do (or actually, not easy to do it fast ^^).
OS: Win 7 Pro x64
RAM: 2x4GB Corsair @ 1600MHz
CPU: Intel i5 760 @ 3.6GHz
Mobo: Asus P7P55D-E
GPU: NVidia GTX 760 2GB
HDD: WD Black 1TB
Sound: VIA VT1828S (onboard)
Peripherals: Razer DeathAdder - Razer DeathStalker - Logitech F310

Posts: 316
Joined: 12 Jul 2012, 03:37

Re: getPlayer() with old token

Post by MuNgLo » 15 May 2013, 16:26

Seems its one hour on ManiaConnect.

The problem is how to decide to call logout. getPlayer cant be used and if I call anything else it just breaks?

Couldn't there be a flag in the player object to flag token as valid or not? I mean if getPlayer() already get preferential treatment to get passed old tokens it should be possible to just stick in a token=>valid without to big changes.

Also I just don't get how this manages to bug out my manialink so much that the whole content requested never shows up. even if that content in itself never goes near the players info.

User avatar
Posts: 1677
Joined: 01 Feb 2012, 19:13
Location: Bordeaux

Re: getPlayer() with old token

Post by magnetik » 23 May 2013, 09:55

The SDK does not use the expiration time which is given by our server. Since I'm working on Oauth2 at the moment, I'll try to find a way to handle this.
ManiaPlanet technical documentation portal (Dedicated, ManiaLink, ManiaScript, Titles...) -- contribute!

Post Reply

Return to “Maniaplanet Web Services”

Who is online

Users browsing this forum: No registered users and 1 guest