PHP-FUT-API
PHP-FUT-API copied to clipboard
Use the same instance API on multiple pages.
Is it possible to use the same API instance, storing it in some way?
I'm trying to store the int within _SESSION, but failed.
Will I have to log in to the API instance for each page?
$api = new \JKetelaar\fut\api\API(
$creds[ 'username' ], $creds[ 'password' ], $creds[ 'secret' ], $creds[ 'key' ], $creds[ 'platform' ]
);
$api->login();
$_SESSION['API'] = $api;
That's a great question, I'll try creating an example for you tonight. I've seen multiple people asking this for question, so it might seem like a feature request :).
Hmm, I've tried clearing some methods and reducing the login time, though this doesn't seem to work (yet). The only thing I could think of right now is serializing the object and storing it.
$toStore = serialize( $api );
Another option is creating a socket for the api and connecting the frontend with that socket.
This would be amazing!
@JKetelaar Using the "serialize ()
" method I get the following error returned.
"Serialization of 'Closure' is not allowed"
My code:
$islogin = $api->login();
if($islogin){
$_SESSION['API'] = serialize($api);
}
exit;
Any news on this issue?