我正在尝试使用 PHP 客户端库在 Google 控制台云中创建一个项目.我从 https://cloud 复制了此示例代码.google.com/resource-manager/reference/rest/v1/projects/create#php
I am trying to create a project in the Google console cloud using the PHP client library. I copied this sample code from https://cloud.google.com/resource-manager/reference/rest/v1/projects/create#php
采取的步骤/遇到问题:
这一行"$requestBody = new Google_Service_CloudResourceManager_Project(); ".
抛出错误:未找到 Google_Service_CloudResourceManager_Project 类".
Throwing error : 'Class Google_Service_CloudResourceManager_Project not found'.
然后我检查了试试这个 API"菜单,我们可以使用 Google API Explorer 将 JSON 传递给 API.我使用 Google API Explorer 进行了测试,结果运行良好.(看截图)
Then I checked in the "Try this API" menu, we can pass the JSON to API with Google API Explorer. I tested with Google API Explorer and the results are working fine. (See screenshot)
注释这一行$requestBody = new Google_Service_CloudResourceManager_Project();";并尝试传递创建方法所需的 json(因为我已经检查了试试这个 API"菜单).
Commenting this line "$requestBody = new Google_Service_CloudResourceManager_Project();"
and trying to pass the json required to create method ( as i have checked in "Try this API" menu).
抛出错误:调用成员函数 create() 在这一行的 null 上"$response = $service->projects->create($requestBody);".
Throwing error : Call to a member function create() on null at this line "$response = $service->projects->create($requestBody);".
我的 Google OAuth 脚本工作正常,只有这个项目创建脚本有问题
PHP 脚本:
$client = new Google_Client();
$client->setApplicationName('Google-CloudResourceManagerSample/0.1');
//$client->useApplicationDefaultCredentials();
$client->addScope('https://www.googleapis.com/auth/cloud-platform');
$service = new Google_Service_CloudResourceManager($client);
// TODO: Assign values to desired properties of `requestBody`:
//$requestBody = new Google_Service_CloudResourceManager_Project();
$requestBody = '{
"name": "bob kris project 2",
"projectId": "bk-project-290016"
}';
$response = $service->projects->create($requestBody);
// TODO: Change code below to process the `response` object:
echo '<pre>', var_export($response, true), '</pre>', "
";
die;
这似乎是 Google 内部的问题.我重新创建了您的场景并得到了相同的结果.我联系了 Cloud App Engine 工程团队并重定向了您的请求.另外,我们已经开通了一个公众票,所有与谷歌的交流都会在那里继续.
It seems that this is a Google internal issue. I recreated your scenario and have the same result. I contacted a Cloud App Engine engineering team and redirected your request. Also, we have already opened a public ticket, and all communication with Google will continue there.
这篇关于如何以编程方式使用 PHP Lib 在 Google Console Cloud 平台中创建项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
在 SELECT(MYSQL/PHP) 中加入 2 个表Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 个表)
如何使<option selected=“selected">由How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 设置?)
使用 PHP 中的数组自动填充选择框Auto populate a select box using an array in PHP(使用 PHP 中的数组自动填充选择框)
PHP SQL SELECT where like search item with multiple wordsPHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode 从 MSSQL-SELECT 产生 JSON_ERROR_UTF8json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 从 MSSQL-SELECT 产生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(),名称 ASCMySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名称 ASC)