PHP - Problems uploading with the Google Drive API

0

Good evening.

I'm trying to upload with the Drive API using the following PHP code:

<?php

require_once 'src/Google/Client.php';
require_once 'src/contrib/Google_DriveService.php';
require_once __DIR__.'/vendor/autoload.php';


$client_id = 'YOUR CLIENT ID';
$client_secret = 'YOUR CLIENT SECRET';
$redirect_uri = 'http://localhost/modeloImpacto.php';
$client = new Google_Client();
$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setRedirectUri($redirect_uri);
//$client->addScope("https://www.googleapis.com/auth/drive");
 $client->setScopes(array('https://www.googleapis.com/auth/drive'));
$service = new Google_Service_Drive($client);

$fileMetadata = new Google_Service_Drive_DriveFile(array(
'name' => 'funcionou.jpg'));
$content = file_get_contents('funcionou.jpg');
$file = $driveService->files->create($fileMetadata, array(
  'data' => $content,
  'mimeType' => 'image/jpeg',
  'uploadType' => 'multipart',
  'fields' => 'id'));
printf("File ID: %s\n", $file->id);

?>

However, I encounter the following error message:

Fatal error: Class 'Google_ServiceResource' not found in C:\wamp64\www\src\contrib\Google_DriveService.php on line 25

Does anyone know what's missing?

Thank you! Raffael Siqueira.

    
asked by anonymous 21.02.2017 / 22:54

0 answers