PHP code example of keboola / google-client-bundle
1. Go to this page and download the library: Download keboola/google-client-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
keboola / google-client-bundle example snippets
use Keboola\Google\ClientBundle\Google\RestApi;
$api = new RestApi($logger); // Optional logger parameter
$api->setAppCredentials($clientId, $clientSecret);
$api->setCredentials($accessToken, $refreshToken);
// Get authorization URL
$authUrl = $api->getAuthorizationUrl(
'http://localhost/callback',
'https://www.googleapis.com/auth/drive.readonly',
'force',
'offline'
);
// Authorize using code
$tokens = $api->authorize($code, 'http://localhost/callback');
// API calls
$response = $api->request('/drive/v2/files');
use Keboola\Google\ClientBundle\Google\RestApi;
$api = RestApi::createWithOAuth(
$clientId,
$clientSecret,
$accessToken,
$refreshToken
);
// Usage same as above
$response = $api->request('/drive/v2/files');