Google API autoload.php missing

I have never used the Goodle API before, and now I'm trying to access my Google Calendar via the API.

I downloaded google-api-php-client-master.zip file, extracted the directory ... / src / Google and copied it to my web server (hosted by a third party, which means that I can’t install anything), According to the samples my code should start with

<?php require_once "Google/Client.php"; require_once "Google/Service/Calendar.php"; .... 

but Client.php throws an error:

Fatal error: require_once (): Could not open the required value '' (include_path = '.: / Usr / lib / php5.4') in / homepages / 39 / d396519017 / htdocs / VC2 / Google / Client.php on line 18

Client.php-Line 18 is the string require_once realpath(dirname(__FILE__) . '/../../autoload.php');

But I can not fint autoload.php anywhere. What am I missing?

Thanks!

+3
source share
1 answer

This is the autoload.php file you are looking for .

It is much better (and easier) not to worry about downloading each class file separately and including this autoload.php file at the top of the examples you will start working with! Make sure you place the file in the folder where the src directory is located.

You can also follow the installation documentation and install the src folder in your include path using:

 set_include_path(get_include_path() . PATH_SEPARATOR . '/path/to/google-api-php-client/src'); 

When performing any of these actions, you must use the use statements to include the necessary classes.

UPDATE: Google has switched to a clean use of Composer in its short-edged versions in accordance with this issue . You must install Composer and run composer require "google/apiclient: ~2.0@dev " to get the autoload.php file you need, or use the v1.xx tag in the repo. I updated the autoload.php link to the last v1 tag.

+7
source

Source: https://habr.com/ru/post/1205452/


All Articles