Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion admin-sdk/directory/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": {
"google/apiclient": "^2.2"
"google/apiclient": "^2.10"
}
}
9 changes: 6 additions & 3 deletions admin-sdk/directory/quickstart.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
throw new Exception('This application must be run on the command line.');
}

use Google\Client;
use Google\Service\Directory;

/**
* Returns an authorized API client.
* @return Google_Client the authorized client object
* @return Client the authorized client object
*/
function getClient()
{
$client = new Google_Client();
$client = new Client();
$client->setApplicationName('G Suite Directory API PHP Quickstart');
$client->setScopes('https://www.googleapis.com/auth/admin.directory.user.readonly');
$client->setAuthConfig('credentials.json');
Expand Down Expand Up @@ -77,7 +80,7 @@ function getClient()

// Get the API client and construct the service object.
$client = getClient();
$service = new Google_Service_Directory($client);
$service = new Directory($client);

// Print the first 10 users in the domain.
try{
Expand Down
2 changes: 1 addition & 1 deletion admin-sdk/reports/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": {
"google/apiclient": "^2.2"
"google/apiclient": "^2.10"
}
}
9 changes: 6 additions & 3 deletions admin-sdk/reports/quickstart.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
throw new Exception('This application must be run on the command line.');
}

use Google\Client;
use Google\Service\Reports;

/**
* Returns an authorized API client.
* @return Google_Client the authorized client object
* @return Client the authorized client object
*/
function getClient()
{
$client = new Google_Client();
$client = new Client();
$client->setApplicationName('Reports API PHP Quickstart');
$client->setScopes('https://www.googleapis.com/auth/admin.reports.audit.readonly');
$client->setAuthConfig('credentials.json');
Expand Down Expand Up @@ -77,7 +80,7 @@ function getClient()

// Get the API client and construct the service object.
$client = getClient();
$service = new Google_Service_Reports($client);
$service = new Reports($client);

// Print the last 10 login events.
$userKey = 'all';
Expand Down
2 changes: 1 addition & 1 deletion admin-sdk/reseller/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": {
"google/apiclient": "^2.2"
"google/apiclient": "^2.10"
}
}
9 changes: 6 additions & 3 deletions admin-sdk/reseller/quickstart.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
throw new Exception('This application must be run on the command line.');
}

use Google\Client;
use Google\Service\Reseller;

/**
* Returns an authorized API client.
* @return Google_Client the authorized client object
* @return Client the authorized client object
*/
function getClient()
{
$client = new Google_Client();
$client = new Client();
$client->setApplicationName('G Suite Reseller API PHP Quickstart');
$client->setScopes("https://www.googleapis.com/auth/apps.order");
$client->setAuthConfig('credentials.json');
Expand Down Expand Up @@ -77,7 +80,7 @@ function getClient()

// Get the API client and construct the service object.
$client = getClient();
$service = new Google_Service_Reseller($client);
$service = new Reseller($client);

// Print the first 10 subscriptions you manage.
$optParams = array(
Expand Down
6 changes: 4 additions & 2 deletions apps-script/execute/execute.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@
// [START apps_script_api_execute]
require __DIR__ . '/vendor/autoload.php';

use Google\Service\Script;

// Get the API client and construct the service object.
$client = getClient();
$service = new Google_Service_Script($client);
$service = new Script($client);

$scriptId = 'ENTER_YOUR_SCRIPT_ID_HERE';

// Create an execution request object.
$request = new Google_Service_Script_ExecutionRequest();
$request = new Script\ExecutionRequest();
$request->setFunction('getFoldersUnderRoot');

try {
Expand Down
2 changes: 1 addition & 1 deletion apps-script/quickstart/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": {
"google/apiclient": "^2.2"
"google/apiclient": "^2.10"
}
}
17 changes: 10 additions & 7 deletions apps-script/quickstart/quickstart.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
throw new Exception('This application must be run on the command line.');
}

use Google\Client;
use Google\Service\Script;

/**
* Returns an authorized API client.
* @return Google_Client the authorized client object
* @return Client the authorized client object
*/
function getClient()
{
$client = new Google_Client();
$client = new Client();
$client->setApplicationName('Google Apps Script API PHP Quickstart');
$client->setScopes("https://www.googleapis.com/auth/script.projects");
$client->setAuthConfig('credentials.json');
Expand Down Expand Up @@ -82,12 +85,12 @@ function getClient()
* project, and log the script's URL to the user.
*/
$client = getClient();
$service = new Google_Service_Script($client);
$service = new Script($client);

// Create a management request object.
try{

$request = new Google_Service_Script_CreateProjectRequest();
$request = new Script\CreateProjectRequest();
$request->setTitle('My Script');
$response = $service->projects->create($request);

Expand All @@ -98,7 +101,7 @@ function helloWorld() {
console.log('Hello, world!');
}
EOT;
$file1 = new Google_Service_Script_ScriptFile();
$file1 = new Script\ScriptFile();
$file1->setName('hello');
$file1->setType('SERVER_JS');
$file1->setSource($code);
Expand All @@ -109,12 +112,12 @@ function helloWorld() {
"exceptionLogging": "CLOUD"
}
EOT;
$file2 = new Google_Service_Script_ScriptFile();
$file2 = new Script\ScriptFile();
$file2->setName('appsscript');
$file2->setType('JSON');
$file2->setSource($manifest);

$request = new Google_Service_Script_Content();
$request = new Script\Content();
$request->setScriptId($scriptId);
$request->setFiles([$file1, $file2]);

Expand Down
2 changes: 1 addition & 1 deletion calendar/quickstart/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": {
"google/apiclient": "^2.2"
"google/apiclient": "^2.10"
}
}
9 changes: 6 additions & 3 deletions calendar/quickstart/quickstart.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
throw new Exception('This application must be run on the command line.');
}

use Google\Client;
use Google\Service\Calendar;

/**
* Returns an authorized API client.
* @return Google_Client the authorized client object
* @return Client the authorized client object
*/
function getClient()
{
$client = new Google_Client();
$client = new Client();
$client->setApplicationName('Google Calendar API PHP Quickstart');
$client->setScopes('https://www.googleapis.com/auth/calendar.events.readonly');
$client->setAuthConfig('credentials.json');
Expand Down Expand Up @@ -77,7 +80,7 @@ function getClient()

// Get the API client and construct the service object.
$client = getClient();
$service = new Google_Service_Calendar($client);
$service = new Calendar($client);

// Print the next 10 events on the user's calendar.
try{
Expand Down
2 changes: 1 addition & 1 deletion classroom/quickstart/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": {
"google/apiclient": "^2.2"
"google/apiclient": "^2.10"
}
}
9 changes: 6 additions & 3 deletions classroom/quickstart/quickstart.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
throw new Exception('This application must be run on the command line.');
}

use Google\Client;
use Google\Service\Classroom;

/**
* Returns an authorized API client.
* @return Google_Client the authorized client object
* @return Client the authorized client object
*/
function getClient()
{
$client = new Google_Client();
$client = new Client();
$client->setApplicationName('Google Classroom API PHP Quickstart');
$client->setScopes('https://www.googleapis.com/auth/classroom.courses.readonly');
$client->setAuthConfig('credentials.json');
Expand Down Expand Up @@ -77,7 +80,7 @@ function getClient()

// Get the API client and construct the service object.
$client = getClient();
$service = new Google_Service_Classroom($client);
$service = new Classroom($client);

// Print the first 10 courses the user has access to.
try{
Expand Down
2 changes: 1 addition & 1 deletion docs/quickstart/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": {
"google/apiclient": "^2.2"
"google/apiclient": "^2.10"
}
}
9 changes: 6 additions & 3 deletions docs/quickstart/quickstart.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
// [START docs_quickstart]
require __DIR__ . '/vendor/autoload.php';

use Google\Client;
use Google\Service\Docs;

/**
* Returns an authorized API client.
* @return Google_Client the authorized client object
* @return Client the authorized client object
*/
function getClient()
{
$client = new Google_Client();
$client = new Client();
$client->setApplicationName('Google Docs API PHP Quickstart');
$client->setScopes('https://www.googleapis.com/auth/documents.readonly ');
$client->setAuthConfig('credentials.json');
Expand Down Expand Up @@ -76,7 +79,7 @@ function expandHomeDirectory($path)

// Get the API client and construct the service object.
$client = getClient();
$service = new Google_Service_Docs($client);
$service = new Docs($client);

// Prints the title of the requested doc:
// https://docs.google.com/document/d/195j9eDD3ccgjQRttHhJPymLJUCOUjs-jmwTrekvdjFE/edit
Expand Down
2 changes: 1 addition & 1 deletion docs/samples/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": {
"google/apiclient": "^2.2",
"google/apiclient": "^2.10",
"duncan3dc/cache": "~0.4"
},
"require-dev": {
Expand Down
9 changes: 6 additions & 3 deletions docs/samples/extract_text.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@
# [START docs_extract_text]
// $documentId = 'YOUR_DOCUMENT_ID';

use Google\Client;
use Google\Service\Docs;

/**
* Create an authorized API client.
* Be sure you've set up your OAuth2 consent screen at
* https://console.cloud.google.com/apis/credentials/consent
*/
$client = new Google_Client();
$client->setScopes(Google_Service_Docs::DOCUMENTS_READONLY);
$client = new Client();
$client->setScopes(Docs::DOCUMENTS_READONLY);
$client->setAuthConfig('credentials.json');
$client->setAccessType('offline');

Expand Down Expand Up @@ -116,7 +119,7 @@ function read_structural_elements($elements)
}

// Fetch the document and print all text elements
$service = new Google_Service_Docs($client);
$service = new Docs($client);
$doc = $service->documents->get($documentId);
echo read_structural_elements($doc->getBody()->getContent());
# [END docs_extract_text]
9 changes: 6 additions & 3 deletions docs/samples/output_as_json.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
}
list($_, $documentId) = $argv;

use Google\Client;
use Google\Service\Docs;

# [START docs_output_as_json]
// $documentId = 'YOUR_DOCUMENT_ID';

Expand All @@ -37,8 +40,8 @@
* Be sure you've set up your OAuth2 consent screen at
* https://console.cloud.google.com/apis/credentials/consent
*/
$client = new Google_Client();
$client->setScopes(Google_Service_Docs::DOCUMENTS_READONLY);
$client = new Client();
$client->setScopes(Docs::DOCUMENTS_READONLY);
$client->setAuthConfig('credentials.json');
$client->setAccessType('offline');

Expand Down Expand Up @@ -73,7 +76,7 @@
}

// Fetch the document and print the results as formatted JSON
$service = new Google_Service_Docs($client);
$service = new Docs($client);
$doc = $service->documents->get($documentId);
print(json_encode((array) $doc, JSON_PRETTY_PRINT));
# [END docs_output_as_json]
2 changes: 1 addition & 1 deletion drive/activity-v2/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": {
"google/apiclient": "^2.2"
"google/apiclient": "^2.10"
}
}
11 changes: 7 additions & 4 deletions drive/activity-v2/quickstart.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
throw new Exception('This application must be run on the command line.');
}

use Google\Client;
use Google\Service\DriveActivity;

/**
* Returns an authorized API client.
* @return Google_Client the authorized client object
* @return Client the authorized client object
*/
function getClient()
{
$client = new Google_Client();
$client = new Client();
$client->setApplicationName('Google Drive Activity API Quickstart');
$client->setScopes('https://www.googleapis.com/auth/drive.activity.readonly');
$client->setAuthConfig('credentials.json');
Expand Down Expand Up @@ -76,10 +79,10 @@ function getClient()

// Get the API client and construct the service object.
$client = getClient();
$service = new Google_Service_DriveActivity($client);
$service = new DriveActivity($client);

// Print the recent activity in your Google Drive.
$request = new Google_Service_DriveActivity_QueryDriveActivityRequest();
$request = new DriveActivity\QueryDriveActivityRequest();
$request->setPageSize(10);
$results = $service->activity->query($request);

Expand Down
Loading