我无法使用PHP客户端库连接到Google API
我无法使用PHP客户端库连接到Google API。
我从一个服务账户的谷歌入门页面开始。但我坚持与这个错误女巫不会告诉我很多关于这个问题我无法使用PHP客户端库连接到Google API
我也试过版本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);
?>
Fatal error: Uncaught Error: Call to undefined function Firebase\JWT\openssl_sign() in C:\www\library\google-api-php-client-2.2.0\vendor\firebase\php-jwt\src\JWT.php:196
Stack trace:
#0 C:\www\library\google-api-php-client-2.2.0\vendor\firebase\php-jwt\src\JWT.php(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.php(1267): Firebase\JWT\JWT::encode(Array, '-----BEGIN PRIV...', 'RS256')
#2 C:\www\library\google-api-php-client-2.2.0\vendor\google\auth\src\OAuth2.php(418): Google\Auth\OAuth2->jwtEncode(Array, '-----BEGIN PRIV...', 'RS256')
#3 C:\www\library\google-api-php-client-2.2.0\vendor\google\auth\src\OAuth2.php(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 on line 196
你缺少OpenSSL的扩展。
取消注释(除去在;
)在php.ini的线,说
;extension=php_openssl.dll
,并重新启动服务器。
谢谢,工作。 –