Apologies if I am missing something obvious in this question...
I have an index.php file where I initialise a Google Client, set the scopes, create a service and start pulling data from the Google Tenancy. This works fine.
<?php
require_once 'vendor/autoload.php';
const CLIENT_ID = MY CLIENT ID;
const CLIENT_SECRET = MY SECRET;
const REDIRECT_URI = REDIRECT URI;
session_start();
$client = new Google_Client();
$client->setApplicationName("My Application");
$client->setClientId(CLIENT_ID);
$client->setClientSecret(CLIENT_SECRET);
$client->setRedirectUri(REDIRECT_URI);
$client->setScopes('admin scopes');
$adminservice = new Google_Service_Directory($client);
My issue is, I want to get a user's ID from the AdminDirectory API and then pass it to a new page, user.php, with the GET tag id.
So, for example:
<?php
$id = $adminservice->users->get(EMAIL)->id;
?>
<a href = 'user.php?id=<?php echo $id; ?>'>Click Here</a>
How do I transfer my $client variable over to this new user.php page?
I have tried putting the client in $_SESSION['client'] and then extracting it on the new page. I have also tried reinitialising the entire client. Neither seem to work.
Thanks