代码之家  ›  专栏  ›  技术社区  ›  Arye Eidelman

我无法使用PHP客户端库连接到google API

  •  0
  • Arye Eidelman  · 技术社区  · 9 年前

    我从谷歌的一个服务账户的入门页面开始。但是我被这个错误困住了,她没有告诉我太多关于这个问题的信息

    我还尝试了该库的2.1.3版本,得到了相同的结果。

    <?php
    ini_set('display_errors', 1); error_reporting(E_ALL);
    require_once __DIR__ . '/../library/google-api-php-client-2.2.0/vendor/autoload.php';
    
    putenv('GOOGLE_APPLICATION_CREDENTIALS=./../secure/some-name-v2-cad7d18fcade.json');
    
    $client = new Google_Client();
    $client->useApplicationDefaultCredentials();
    
    $driveService = new Google_Service_Drive($client);
    
    $fileId = "0B9w-wSwYgo9ZU0toRFc3R1A5dlG";
    $optParams = array();
    $response = $driveService->files->get($fileId, $optParams); // Error on this line.
    
    var_dump($response);
    ?>
    

    C: \www\library\google-api-php-client-2.2.0\vendor\firebase\php-jwt\src\jwt。菲律宾比索:196

    堆栈跟踪:

    #0 C:\www\library\google-api-php-client-2.2.0\vendor\firebase\php-jwt\src\jwt。菲律宾比索(167): Firebase\JWT\JWT::sign('eyJ0eXAiOiJKV1Q…','----BEGIN PRIV….,'RS256')

    #1 C:\www\library\google-api-php-client-2.2.0\vendor\google\auth\src\OAuth2。菲律宾比索(1267): Firebase\JWT\JWT::encode(数组,'----BEGIN PRIV….,'RS256')

    Google\Auth\OAuth2->jwtEncode(数组,'----BEGIN PRIV….,'RS256')

    #3 C:\www\library\google-api-php-client-2.2.0\vendor\google\auth\src\OAuth2。菲律宾比索(451): Google\Auth\OAuth2->toJwt()

    #4 C:\www in C:\www\library\google-api-php-client-2.2.0\vendor\firebase\php-jwt\src\jwt。php第196行

    1 回复  |  直到 9 年前
        1
  •  2
  •   Finwe    9 年前

    您缺少openssl扩展。

    取消注释(删除 ; on)php中的行。ini其中说

    ;extension=php_openssl.dll
    

    然后重新启动服务器。

    推荐文章