PHP-FUT-API icon indicating copy to clipboard operation
PHP-FUT-API copied to clipboard

Use the same instance API on multiple pages.

Open JoaoFelipePego opened this issue 7 years ago • 5 comments

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;

JoaoFelipePego avatar May 02 '17 00:05 JoaoFelipePego

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 :).

JKetelaar avatar May 02 '17 07:05 JKetelaar

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.

JKetelaar avatar May 02 '17 11:05 JKetelaar

This would be amazing!

ToniKuipers avatar May 04 '17 18:05 ToniKuipers

@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;

JoaoFelipePego avatar May 05 '17 00:05 JoaoFelipePego

Any news on this issue?

ToniKuipers avatar May 19 '17 15:05 ToniKuipers