Created
July 5, 2017 17:47
-
-
Save ultimateprogramer/258ad19aae2a5a3aa9e2c6deb29f951c to your computer and use it in GitHub Desktop.
Using Client Secrets with Google API PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| require_once __DIR__.'/vendor/autoload.php'; | |
| // For PHP you will need to define GOOGLE_APPLICATION_CREDENTIALS environment variable and point it to the path of the file | |
| // You do not need to do this for Google App Engine | |
| putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json'); | |
| $client = new Google_Client(); | |
| $client->useApplicationDefaultCredentials(); | |
| // Sample call done to the SQL Admin | |
| $sqladmin = new Google_Service_SQLAdmin($client); | |
| $response = $sqladmin->instances | |
| ->listInstances('examinable-example-123')->getItems(); | |
| echo json_encode($response) . "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment