php-snapchat icon indicating copy to clipboard operation
php-snapchat copied to clipboard

Token saved in session: check token and reconnect only if necessary (invalid token).

Open ghost opened this issue 10 years ago • 4 comments

Hello,

I save the object "$snapchat" in session with this method: http://www.php.net/manual/en/oop4.serialization.php This avoids having to redo a connection (with a new token) on Snapchat servers at each change of page.

But if I connect to Snapchat with mobile application, it makes a new connection and changes the token. So, the old token saved in PHP session (on my website) is no longer valid.

My question is the following: How to check if the token is still valid? If it is still valid, use it normally. But, if it is no longer valid, make a new connection (reconnect with the login() function).

Thank you in advance.

Best regards, Yoann

ghost avatar Apr 15 '14 09:04 ghost

You could try making a call without any side effects, like getFriends().

philihp avatar Apr 15 '14 20:04 philihp

If the person no friends? What's going on? It is not preferable to use getUpdates()?

ghost avatar Apr 15 '14 20:04 ghost

I suppose you could do that too.

philihp avatar Apr 15 '14 20:04 philihp

Ok! It would be nice to add a tokenIsValid() function in the future (next update).

ghost avatar Apr 15 '14 20:04 ghost