PHP致命错误:未捕获错误:在... / Client.php:954中找不到类'Google \ Auth \ OAuth2'

时间:2019-05-31 07:15:03

标签: php google-oauth

以下线程无法为我解决:-

Fatal error: Class 'Google\Auth\OAuth2' not found

Class 'Google\Auth\OAuth2' not found

Fatal error: Uncaught Error: Class 'Google_Client' not found

甚至是这个:-

Implementing Oauth2 login, Fatal error: Class 'Google_Service' not found

大家好,

来自error_log的确切日志如下:-

PHP Fatal error:  Uncaught Error: Class 'Google\Auth\OAuth2' not found in /home/.../public_html/.../google/Client.php:954
Stack trace:
#0 /home/.../public_html/.../google/Client.php(943): Google_Client->createOAuth2Service()
#1 /home/.../public_html/.../google/Client.php(338): Google_Client->getOAuth2Service()
#2 /home/.../public_html/.../logintest.php(39): Google_Client->createAuthUrl()
#3 {main}
  thrown in /home/.../public_html/.../google/Client.php on line 954

下面是Client.php中的几行

  public function getOAuth2Service()
  {
    if (!isset($this->auth)) {
      $this->auth = $this->createOAuth2Service();
    }

    return $this->auth;
  }

  /**
   * create a default google auth object
   */
  protected function createOAuth2Service()
  {
    $auth = new OAuth2(
        [
          'clientId'          => $this->getClientId(),
          'clientSecret'      => $this->getClientSecret(),
          'authorizationUri'   => self::OAUTH2_AUTH_URL,
          'tokenCredentialUri' => self::OAUTH2_TOKEN_URI,
          'redirectUri'       => $this->getRedirectUri(),
          'issuer'            => $this->config['client_id'],
          'signingKey'        => $this->config['signing_key'],
          'signingAlgorithm'  => $this->config['signing_algorithm'],
        ]
    );

    return $auth;
  }

堆栈跟踪的第3行(对我而言)指示autoload.php和Client.php的包含正确完成

我在共享主机上,这就是为什么无法通过Composer安装的原因。我只是下载并复制了文件(按照https://github.com/googleapis/google-api-php-client#installation)。

这就是我包含文件的方式

set_include_path(get_include_path() . PATH_SEPARATOR . '/../google/');
include_once __DIR__ . '/../google/autoload.php';
require_once 'google/Client.php';
require_once 'google/Service.php';

PHP代码以下行中的错误触发器:-

$url = $client->createAuthUrl();

请帮助!

0 个答案:

没有答案