Php 首次使用google oauth时出错
我遵循google提供的教程使用google oauth。我以前从未做过。我自上而下地遵循教程,在凭证页面中创建了一个新的应用程序,等等,但是,我失败了。我正在我的主服务器上尝试这个。我给出了以下错误:Php 首次使用google oauth时出错,php,oauth,google-oauth,Php,Oauth,Google Oauth,我遵循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 /ho
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
教程链接是
我使用的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));
}
?>
我在谷歌上搜索了一下,发现每个教程看起来都是一样的,除了一些要求谷歌硬盘信息、一些谷歌分析或谷歌+个人资料的部分。
那么我错在哪里呢
多谢各位 您在
require\u once
中的路径错误。在本教程中,它是require_once uuu DIR_uuu.'/vendor/autoload.php'代码>。第一次部署composer时别忘了运行它。谢谢。我离开了php/laravel。然而,我会接受它,猜测它的正确答案。