我已经安装了google api php与composer,并上传供应商文件夹到我的服务器。
php composer.phar require google/apiclient:^2.0
代码:getVideo.php
<?
require_once __DIR__ . '/vendor/autoload.php';
define('ID_VIDEO', '0B9SXFdezvkZtOE9xVlVNR3U0a1U');
$client = new Google_Client();
$client->setApplicationName("LOAD_VIDEO");
$client->setDeveloperKey("AIzaSyD1AVpO4qBgH0JmQOEU_xxxx");
$client->addScope(Google_Service_Drive::DRIVE);
$client->setAccessType('offline_access');
session_start();
if (isset($_SESSION['token'])) {
$client->setAccessToken($_SESSION['token']);
}
$service = new Google_DriveService($client);
$file = $service->files->get(ID_VIDEO);
$access_toke = json_decode($client->getAccessToken(), TRUE);
$access_toke = $access_toke['access_token'];
?>
<embed width="100%" height="100%" name="plugin" src="<?= urldecode($file['embedLink']);?>&access_token=<?= $access_toke;?>" type="application/x-shockwave-flash" >
I got error code:
致命错误:在/home/myserver/public_html/getVideo.php第18行没有找到'Google_DriveService'类
我在文件夹vendor中找不到google_driveservice文件,我错过了什么吗?
查看存储库,类名是Google_Service_Drive
。
更新:同样根据客户端的自述
我有一个错误,为了修复它,我已经将Google_DriveService更改为Google_Service_Drive,工作良好。把
$service = new Google_DriveService($client);
$service = new Google_Service_Drive($client);