脚本宝典收集整理的这篇文章主要介绍了使用带有PHP的google驱动器api将文件上传到特定文件夹,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
<?PHP error_reporting(E_ALL); ini_set('display_errors',1); require_once 'GOOGLE-api-PHP-client/src/Google_Client.PHP'; require_once 'google-api-PHP-client/src/contrib/Google_DriveService.PHP'; $client = new Google_Client(); // Get your credentials From the APIs Console $client->setClientId('***'); $client->setClientSecret('***'); $client->setRedirectUri('http://***'); $client->setScoPEs(array('https://www.googleapis.COM/auth/drive')); if(empty($_GET['code'])) { $client->authenticate(); } $myfile= "video.mp4"; $type='video/mp4'; $service = new Google_DriveService($client); // Exchange authorization code for access token $accessToken = $client->authenticate($_GET['code']); $client->setAccessToken($accessToken); //Insert a file $file = new Google_DriveFile(); $file->setTITle('filename.mp4'); $file->setDescription('A video'); $file->setMimeType($type); $data = file_get_contents($myfile); $createDFile = $service->files->insert($file,array( 'data' => $data,'mimeType' => $type,)); PRint_r($createdFile); echo "<br />";
//Set the Parent Folder $parent = new Google_Service_Drive_ParentReference(); //prevIoUsly Google_ParentReference $parent->setId('0B9mYBlahBlahBlah'); $file->setParents(array($parent));
以上是脚本宝典为你收集整理的使用带有PHP的google驱动器api将文件上传到特定文件夹全部内容,希望文章能够帮你解决使用带有PHP的google驱动器api将文件上传到特定文件夹所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。