Reputation: 135
I'm still stuck on this question and I'm rephrasing it after a bit more exploration.
I cannot find code examples for using google-api-php-client with v1 API
methods like projects/setIamPolicy()
On this example
The PHP example appears to be broken because $service->projects
is undefined. The equivalent nodejs example "just works".
I've attempted to switch to the v1-master branch, but the same code is still incompatible. I've attempted some modifications to compensate for v2 authentication methods used in the example, but hit a dead end.
What is the proper way to use v1 methods via PHP?
EDIT It looks like this simple composer file is my solution:
{
"require": {
"google/apiclient": "^2.0",
"google/apiclient-services": "0.50"
}
}
Upvotes: 1
Views: 341
Reputation: 1221
After reproducing the documentation instructions, I came across the same error of undefined property $projects in $service. It seems that the documentation examples for PHP Cloud Resource Manager API v1 are defining classes (like $service = new Google_Service_CloudResourceManager($client);) that are actually implemented in v2.
v1 Library contains variables $organizations and $projects.
v2 Library contains variables $folders and $operations.
In the documentation example, the script tries to access $projects, using the v2 Class, where $projects doesn’t exist, but $folders and $operations do.
By using a version of google-api-php-client-services Library, which includes the latest version n of v1, you can access $folders, $liens, $operations, $organizations, $projects but still use V2 Classes of google-api-php-client.
Upvotes: 1