【发布时间】:2016-07-15 02:55:37
【问题描述】:
我正在按照 google 提供的教程使用 google oauth。我以前从来没有做过。我从上到下按照教程,在凭据页面等中创建了一个新应用程序,但是,我失败了。我正在我的主服务器上尝试这个。我给出了以下错误:
Warning: require_once(/home/storxlbq/public_html/google/google-api-php-client/autoload.php): failed to open stream: No such file or directory in /home/storxlbq/public_html/google/index.php on line 2
Fatal error: require_once(): Failed opening required '/home/storxlbq/public_html/google/google-api-php-client/autoload.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/storxlbq/public_html/google/index.php on line 2
教程链接是here
我使用的php代码在这里:
<?php
require_once dirname(__FILE__) . '/google-api-php-client/autoload.php';
session_start();
$client = new Google_Client();
$client->setAuthConfigFile('client_secrets.json');
$client->addScope(Google_Service_Drive::DRIVE_METADATA_READONLY);
if (isset($_SESSION['access_token']) && $_SESSION['access_token'])
{
$client->setAccessToken($_SESSION['access_token']);
$drive_service = new Google_Service_Drive($client);
$files_list = $drive_service->files->listFiles(array())->getItems();
echo json_encode($files_list);
}
else
{
$redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . '/google/callback.php';
header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
}
?>
我用谷歌搜索了一下,发现每个教程看起来都一样,除了一些要求谷歌驱动器信息、一些谷歌分析或谷歌+个人资料的部分。 那么我哪里错了?
谢谢。
【问题讨论】:
标签: php oauth google-oauth