php – 实现Oauth2登录,致命错误:找不到类’Google_Service’
发布时间:2020-12-13 13:16:53 所属栏目:PHP教程 来源:网络整理
导读:我正在将我的网站登录系统从LightOpenID更新为Google的Oauth 2.0. 当我需要Client.php和Service / Oauth2.php时,我收到错误 Fatal error: Class ‘Google_Service’ not found in /home/myname/repos/website_current/lib/google-api-php-client/src/Google/
我正在将我的网站登录系统从LightOpenID更新为Google的Oauth 2.0.
当我需要Client.php和Service / Oauth2.php时,我收到错误
我使用的代码(来自我的login.php文件)看起来像这样 require_once(dirname($_SERVER['DOCUMENT_ROOT']).'/lib/autoload.php'); require('Google/Client.php'); require('Google/Service/Oauth2.php'); echo "exit"; exit(); 我在PHP.ini中添加了include路径(在/etc/php5/apache2/php.ini中) include_path = ".:/usr/local/lib/php:/home/myname/repos/website_current/lib/google-api-php-client/src" 所以看来我的Oauth2.php文件看不到任何其他包含的类’Google_Service’,它是’Service.php’中的一个文件夹. 我的文件夹结构如下所示: lib/ ... autoload.php ... functions.php ... google-api-php-client/ ... src/ ... Google/ (etc etc) public_html/ ... login/ ...login.php 我不知道为什么会这样.应该看到包含路径,并使用phpinfo()显示为包含的路径;有人可以给我一些见解吗?
确保在任何其他Google“require_once”行之前添加该行.
require_once 'google-api-php-client/autoload.php'; 我把它弄到最后,它让我挠了头10分钟. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |