第1步:下载google-api-php-client
第2步:将目录名称更改为“api”并上传到Google App Engine
第3步:关注instructions并继续添加以下行,因为特定错误说文件丢失
set_include_path( get_include_path() . PATH_SEPARATOR . 'api/src' );
require_once 'Google/Collection.php';
require_once 'Google/Model.php';
require_once 'Google/Exception.php';
require_once 'Google/Task/Exception.php';
require_once 'Google/Service.php';
require_once 'Google/Service/Resource.php';
require_once 'Google/Service/Gmail.php';
步骤4:收到以下错误(对删除的项目使用{...}),
Warning: require_once(/base/data/home/apps/{...}/api/src/Google/autoload.php):
failed to open stream: No such file or directory in
/base/data/home/apps/{...}/api/src/Google/Collection.php on line 4 Fatal
error: require_once(): Failed opening required '/base/data/home/apps/{...}/api/src/Google/autoload.php'
(include_path='.;/base/data/home/{...}/;/base/data/home/runtimes/php/sdk;api/src')
in /base/data/home/apps/{...}/api/src/Google/Collection.php on line 4
其他文件需要“Collection.php”文件,但它需要“autoload.php”文件。没有“autoload.php”文件。我搜索了几个小时,完全迷失了。为什么他们是一个不存在的文件的依赖项,如果需要以某种方式创建它,为什么要埋葬指令呢?
我想要做的就是用它来检查未读电子邮件,API不起作用吗?还有另一种方法可以检查用户未读电子邮件到GAE中吗?
答案 0 :(得分:2)
您需要的文件是here
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function google_api_php_client_autoload($className) {
$classPath = explode('_', $className);
if ($classPath[0] != 'Google') {
return;
}
// Drop 'Google', and maximum class file path depth in this project is 3.
$classPath = array_slice($classPath, 1, 2);
$filePath = dirname(__FILE__) . '/' . implode('/', $classPath) . '.php';
if (file_exists($filePath)) {
require_once($filePath);
}
}
spl_autoload_register('google_api_php_client_autoload');
请尝试使用它并让我知道它是否适合您。
答案 1 :(得分:0)
我看到有composer.json。你运行
composer install
答案 2 :(得分:0)
source shows看起来像是一个错误(?),如果它找不到Google_Client
,那么它会尝试包含autoload.php
文件。
将此添加为您的第一个包含
require_once 'Google/Client.php';
编辑所以是的,不仅如此,而且看起来你还需要像mnv那样运行作曲家。
答案 3 :(得分:0)
上周,GitHub有autoload.php文件,本周它没有。我不太热衷于使用作曲家 - 叫我老学校
以上是我上周提供的autoload.php文件的内容,可能对您有帮助吗?
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// PHP 5.2 compatibility: E_USER_DEPRECATED was added in 5.3
if (!defined('E_USER_DEPRECATED')) {
define('E_USER_DEPRECATED', E_USER_WARNING);
}
$error = "google-api-php-client's autoloader was moved to src/Google/autoload.php in 1.1.3. This ";
$error .= "redirect will be removed in 1.2. Please adjust your code to use the new location.";
trigger_error($error, E_USER_DEPRECATED);
require_once dirname(__FILE__) . '/src/Google/autoload.php';
答案 4 :(得分:0)
Google Cache had the file, http://webcache.googleusercontent.com/search?q=cache:992oyuQ76a0J:https://github.com/google/google-api-php-client/blob/master/src/Google/autoload.php+&cd=1&hl=en&ct=clnk&gl=us
Maybe it got removed by mistake, not sure.