Google API PHP客户端自动加载.PHP是必需的,但缺少


Google API PHP Client autoload.php is required but missing?

步骤1:下载google api php客户端

步骤2:将目录名更改为"api"并上传到谷歌应用程序引擎

步骤3:按照说明,并不断添加以下行,因为特定的错误说文件丢失

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中未读的电子邮件?

您需要的文件在这里

<?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');

请尝试使用它,并让我知道它是否对你有效。

源代码显示了一个看起来像bug(?)的内容,如果它找不到Google_Client,则会尝试包含一个autoload.php文件。

添加此作为您的第一个包含

require_once 'Google/Client.php';

edit所以,是的,不仅如此,而且看起来你还需要像mnv所说的那样运行composer。

上周,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';

Google Cache拥有该文件,http://webcache.googleusercontent.com/search?q=cache:992oyuQ76a0J:https://github.com/google/google-api php客户端/bob/master/src/Google/autoload.php+&cd=1&hl=en&ct=clnk&gl=us

也许它被错误地删除了,不确定。