Google API PHP 需要客户端 autoload.php 但缺少?

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

第 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 中?

我看到有 composer.json。你运行

作曲家安装

?

source shows 看起来像一个 bug(?),如果它找不到 Google_Client 那么它会尝试包含一个 autoload.php 文件。

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

require_once 'Google/Client.php';

编辑 所以是的,不仅如此,而且看起来你还需要像 mnv 所说的那样 运行 作曲家。

上周,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缓存有文件,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

可能是误删除了,不确定。

您需要的文件是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');

请尝试使用它,如果它对你有用,请告诉我。