\n"; if ($_SERVER['PHP_SELF'] != "/index.php") { $ret .= "

Back

"; } $ret .= "

" . $title . "

"; // Start the session (for storing access tokens and things) if (!headers_sent()) { session_start(); } return $ret; } function pageFooter($file = null) { $ret = ""; if ($file) { $ret .= "

Code:

"; $ret .= "
";
    $ret .= htmlspecialchars(file_get_contents($file));
    $ret .= "
"; } $ret .= ""; return $ret; } function missingApiKeyWarning() { $ret = "

Warning: You need to set a Simple API Access key from the Google API console

"; return $ret; } function missingClientSecretsWarning() { $ret = "

Warning: You need to set Client ID, Client Secret and Redirect URI from the Google API console

"; return $ret; } function missingServiceAccountDetailsWarning() { $ret = "

Warning: You need download your Service Account Credentials JSON from the Google API console.

Once downloaded, move them into the root directory of this repository and rename them 'service-account-credentials.json'.

In your application, you should set the GOOGLE_APPLICATION_CREDENTIALS environment variable as the path to this file, but in the context of this example we will do this for you.

"; return $ret; } function missingOAuth2CredentialsWarning() { $ret = "

Warning: You need to set the location of your OAuth2 Client Credentials from the Google API console.

Once downloaded, move them into the root directory of this repository and rename them 'oauth-credentials.json'.

"; return $ret; } function checkServiceAccountCredentialsFile() { // service account creds $application_creds = __DIR__ . '/../../service-account-credentials.json'; return file_exists($application_creds) ? $application_creds : false; } function getOAuthCredentialsFile() { // oauth2 creds $oauth_creds = __DIR__ . '/../../oauth-credentials.json'; if (file_exists($oauth_creds)) { return $oauth_creds; } return false; } function setClientCredentialsFile($apiKey) { $file = __DIR__ . '/../../tests/.apiKey'; file_put_contents($file, $apiKey); } function getApiKey() { $file = __DIR__ . '/../../tests/.apiKey'; if (file_exists($file)) { return file_get_contents($file); } } function setApiKey($apiKey) { $file = __DIR__ . '/../../tests/.apiKey'; file_put_contents($file, $apiKey); }