You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Set the scopes required for the API you are going to call
214
214
215
215
```php
216
-
$client->addScope(Google_Service_Drive::DRIVE);
216
+
$client->addScope(Google\Service\Drive::DRIVE);
217
217
```
218
218
219
219
1. If you have delegated domain-wide access to the service account and you want to impersonate a user account, specify the email address of the user account using the method setSubject:
@@ -264,10 +264,10 @@ Using this library, the same call would look something like this:
264
264
265
265
```php
266
266
// create the datastore service class
267
-
$datastore = new Google_Service_Datastore($client);
267
+
$datastore = new Google\Service\Datastore($client);
268
268
269
269
// build the query - this maps directly to the JSON
270
-
$query = new Google_Service_Datastore_Query([
270
+
$query = new Google\Service\Datastore\Query([
271
271
'kind' => [
272
272
[
273
273
'name' => 'Book',
@@ -283,28 +283,28 @@ $query = new Google_Service_Datastore_Query([
283
283
]);
284
284
285
285
// build the request and response
286
-
$request = new Google_Service_Datastore_RunQueryRequest(['query' => $query]);
286
+
$request = new Google\Service\Datastore\RunQueryRequest(['query' => $query]);
However, as each property of the JSON API has a corresponding generated class, the above code could also be written like this:
291
291
292
292
```php
293
293
// create the datastore service class
294
-
$datastore = new Google_Service_Datastore($client);
294
+
$datastore = new Google\Service\Datastore($client);
295
295
296
296
// build the query
297
-
$request = new Google_Service_Datastore_RunQueryRequest();
298
-
$query = new Google_Service_Datastore_Query();
297
+
$request = new Google\Service\Datastore_RunQueryRequest();
298
+
$query = new Google\Service\Datastore\Query();
299
299
// - set the order
300
-
$order = new Google_Service_Datastore_PropertyOrder();
300
+
$order = new Google\Service\Datastore_PropertyOrder();
301
301
$order->setDirection('descending');
302
-
$property = new Google_Service_Datastore_PropertyReference();
302
+
$property = new Google\Service\Datastore\PropertyReference();
303
303
$property->setName('title');
304
304
$order->setProperty($property);
305
305
$query->setOrder([$order]);
306
306
// - set the kinds
307
-
$kind = new Google_Service_Datastore_KindExpression();
307
+
$kind = new Google\Service\Datastore\KindExpression();
308
308
$kind->setName('Book');
309
309
$query->setKinds([$kind]);
310
310
// - set the limit
@@ -335,7 +335,7 @@ $client = new Google\Client();
335
335
* Application Default Credentials.
336
336
*/
337
337
$client->useApplicationDefaultCredentials();
338
-
$client->addScope(Google_Service_Plus::PLUS_ME);
338
+
$client->addScope(Google\Service\Plus::PLUS_ME);
339
339
340
340
// returns a Guzzle HTTP Client
341
341
$httpClient = $client->authorize();
@@ -438,9 +438,9 @@ If there is a specific bug with the library, please [file an issue](https://gith
438
438
439
439
If X is a feature of the library, file away! If X is an example of using a specific service, the best place to go is to the teams for those specific APIs - our preference is to link to their examples rather than add them to the library, as they can then pin to specific versions of the library. If you have any examples for other APIs, let us know and we will happily add a link to the README above!
440
440
441
-
### Why does Google_..._Service have weird names? ###
441
+
### Why do some Google\Service classes have weird names? ###
442
442
443
-
The _Service classes are generally automatically generated from the API discovery documents: https://developers.google.com/discovery/. Sometimes new features are added to APIs with unusual names, which can cause some unexpected or non-standard style naming in the PHP classes.
443
+
The _Google\Service_ classes are generally automatically generated from the API discovery documents: https://developers.google.com/discovery/. Sometimes new features are added to APIs with unusual names, which can cause some unexpected or non-standard style naming in the PHP classes.
444
444
445
445
### How do I deal with non-JSON response types? ###
Copy file name to clipboardExpand all lines: docs/media.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ The PHP client library allows for uploading large files for use with APIs such a
7
7
In the simple upload case, the data is passed as the body of the request made to the server. This limits the ability to specify metadata, but is very easy to use.
With multipart file uploads, the uploaded file is sent as one part of a multipart form post. This allows metadata about the file object to be sent as part of the post as well. This is triggered by specifying the _multipart_ uploadType.
It is also possible to split the upload across multiple requests. This is convenient for larger files, and allows resumption of the upload if there is a problem. Resumable uploads can be sent with separate metadata.
Copy file name to clipboardExpand all lines: docs/oauth-server.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -87,7 +87,7 @@ Use the authorized `Google\Client` object to call Google APIs by completing the
87
87
1. Build a service object for the API that you want to call, providing the authorized `Google\Client` object. For example, to call the Cloud SQL Administration API:
88
88
89
89
```php
90
-
$sqladmin = new Google_Service_SQLAdmin($client);
90
+
$sqladmin = new Google\Service\SQLAdmin($client);
91
91
```
92
92
93
93
2. Make requests to the API service using the [interface provided by the service object](https://github.com/googleapis/google-api-php-client/blob/master/docs/start.md#build-the-service-object). For example, to list the instances of Cloud SQL databases in the examinable-example-123 project:
Scopes enable your application to only request access to the resources that it needs while also enabling users to control the amount of access that they grant to your application. Thus, there is an inverse relationship between the number of scopes requested and the likelihood of obtaining user consent. To set this value in PHP, call the `addScope` function:
The [OAuth 2.0 API Scopes](https://developers.google.com/identity/protocols/googlescopes) document provides a full list of scopes that you might use to access Google APIs.
@@ -284,7 +284,7 @@ Use the access token to call Google APIs by completing the following steps:
284
284
2. Build a service object for the API that you want to call. You build a a service object by providing an authorized `Google\Client` object to the constructor for the API you want to call. For example, to call the Drive API:
285
285
286
286
```php
287
-
$drive = new Google_Service_Drive($client);
287
+
$drive = new Google\Service\Drive($client);
288
288
```
289
289
290
290
3. Make requests to the API service using the [interface provided by the service object](start.md). For example, to list the files in the authenticated user's Google Drive:
Copy file name to clipboardExpand all lines: docs/parameters.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Standard Parameters
2
2
3
-
Many API methods include support for certain optional parameters. In addition to these there are several standard parameters that can be applied to any API call. These are defined in the `Google_Service_Resource` class.
3
+
Many API methods include support for certain optional parameters. In addition to these there are several standard parameters that can be applied to any API call. These are defined in the `Google\Service\Resource` class.
Services are called through queries to service specific objects. These are created by constructing the service object, and passing an instance of `Google\Client` to it. `Google\Client` contains the IO, authentication and other classes required by the service to function, and the service informs the client which scopes it uses to provide a default when authenticating a user.
0 commit comments