[英]Problems with Google API Client Library for PHP
我正在嘗試將適用於PHP的Google API客戶端庫與我的應用程序集成,以驗證某些代碼是否真實。
根據他們的說明,有2種方法可以執行此操作。 首先是使用composer(我沒有經過),其次是從https://github.com/google/google-google-api-php-client/下載zip文件並將其移動到服務器中的某個位置; 我做到了 到現在為止還挺好。
然后,根據Google
Uncompress the zip file you download, and include the autoloader in your project: require_once '/path/to/google-api-php-client/vendor/autoload.php';
這樣做的主要原因是運行以下代碼進行檢查。
// Get $id_token via HTTPS POST.
$client = new Google_Client(['client_id' => $CLIENT_ID]);
$payload = $client->verifyIdToken($id_token);
if ($payload) {
$userid = $payload['sub'];
// If request specified a G Suite domain:
//$domain = $payload['hd'];
} else {
// Invalid ID token
}
但是,我從以下行中收到致命錯誤:
require_once 'require_once '/var/www/html/various/google-api-php-client-2.1.1/vendor/autoload.php';
使用error_reporting(E_ALL);
的錯誤error_reporting(E_ALL);
和ini_set('display_errors', 1);
是:
<br />
<b>Warning</b>: require_once(/var/www/html/various/google-api-php-client-2.1.1/vendor/autoload.php): failed to open stream: No such file or directory in <b>/var/www/html/php/insert.php</b> on line <b>7</b><br />
<br />
<pre>
<b>Fatal error</b>: require_once(): Failed opening required '/var/www/html/various/google-api-php-client-2.1.1/vendor/autoload.php' (include_path='.:/usr/share/php') in <b>/var/www/html/php/insert.php</b> on line <b>6</b><br />
</pre>
目前,我的insert.php代碼是:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
include_once ('/var/www/db/connection.php');
require_once '/var/www/html/various/google-api-php-client-2.1.1/vendor/autoload.php';
$value = json_decode(file_get_contents('php://input'));
?>
我可能做錯了什么?
在繼續之前,請檢查指定路徑中是否存在文件autoload.php。
然后,您可以下載並使用發布包,因為鏈接到的GitHub存儲庫是與composer一起使用的。 該發行包可在Google Releases中找到
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.