本地主机上的谷歌服务帐户


Google Service Accounts on localhost

我正在使用Google Apps for Work,并且有一个服务帐户可以访问PHP中的Drive API。

我现在的代码是:

$client = new Google_Client();
$client->setApplicationName('MyApp');
$key = file_get_contents("/path/to/secure/key");
$cred = new Google_Auth_AssertionCredentials(
      "serviceaccount@myapp.iam.gserviceaccount.com",
      array('https://www.googleapis.com/auth/drive', 'https://spreadsheets.google.com/feeds'),
      $key, 'keysecretgoeshere', 'http://oauth.net/grant_type/jwt/1.0/bearer', "email@domain.com"
    );
$client->setAssertionCredentials($cred);

当我将它上传到外部托管的Apache服务器时,这一点非常有效。奇怪的是,我还有一个本地服务器,使用EasyHP在本地测试它,当我访问页面时,我会收到一个"无法访问此网站。连接已重置"的错误。

我有没有遗漏一些东西,为什么它不能在本地主机上工作?可能是没有安装PHP扩展,或者是一些cURL/openSSL问题?

在每一点中断代码后,OpenSSL就出现了问题。解决方案可以在这里找到:

PHP openssl_sign DIES