Google API autoload.php missing

纵饮孤独 提交于 2019-12-29 08:54:35

问题


I never used the Goodle API before, and now I try to get my feet wet accessing Google calendar via the API.

I downloaded the google-api-php-client-master.zip, extracted the .../src/Google directory and copied it to my webserver (hosted by a 3rd party, which means I can't install anything). According to the samples my code needs to start with

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

but the Client.php throws an error:

Fatal error: require_once(): Failed opening required '' (include_path='.:/usr/lib/php5.4') in /homepages/39/d396519017/htdocs/VC2/Google/Client.php on line 18

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

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

Thanks!


回答1:


This is the autoload.php file that you're looking for.

It is much better (and easier) to not worry about loading each class file individually and including this autoload.php file at the top of the examples that you're going to start working with! Make sure you place the file at the folder that holds the src directory.

You could also follow the installation documentation and set the src folder in your include path using:

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

When doing either of these things, you must instead utilize use statements to include the classes that you need.

UPDATE: Google has moved to purely using Composer in its bleeding edge versions as per this issue. You should install Composer and run composer require "google/apiclient:~2.0@dev" to get the autoload.php file you need, or use a v1.x.x tag in the repo. I've updated the autoload.php link to the latest v1 tag.



来源:https://stackoverflow.com/questions/26983877/google-api-autoload-php-missing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!