开发者

how to use the Google Docs API from PHP on a shared hosting plan?

开发者 https://www.devze.com 2023-02-27 05:29 出处:网络
I would like to read-write specific cells in a Google Spreadsheet, but I\'m puzzled by the lot of information on the internet about how to do it. I only have access to shared hosting (which means an F

I would like to read-write specific cells in a Google Spreadsheet, but I'm puzzled by the lot of information on the internet about how to do it. I only have access to shared hosting (which means an FTP access and a control panel), not a virtual server.

In the Google Docs official API page it only has PHP support in version 1, which says its deprecated, and it's already at version 3, so I shouldn't start using that.

On this page: http://code.google.com/apis/gdata/docs/client-libraries.html it says that the PHP client library is

Distributed as part of zend.

while on this page: http://code.google.com/apis/gdata/articles/php_client_lib.html it says

The client library is part of the open-source Zend Framework but can also be downloaded as a standalone version.

My biggest problem is that I have never used Zend and I don't know how to use it or how to install/update its packages. Is it possible to install/update this framework and its packages from a simple shared hosting user? Or I'm stuck with what I find on 开发者_如何学Goa particular hosting company's servers?

I've downloaded the latest version from this page: http://framework.zend.com/download/gdata and in its INSTALL file it says:

Zend Framework requires no special installation steps. Simply download the framework, extract it to the folder you would like to keep it in, and add the library directory to your PHP include_path. To use components in the extras library, add the extras/library directory to your PHP include_path, as well. If you would like to use Zend_Tool, simply add bin/zf.bat (for Windows) or bin/zf.sh (for anything else) to your system executable path.

I think include_path means some variable in php.ini, not something what I have access to. Can I just simply download/extract zend to my folder and do include_once() at a start of my code?


You will want to contact your hosting provider to see if they have the Zend framework installed. If they do, ask them for the include path.

If not, you can download the library, unzip it, and upload it to your web root.

The GDATA module is part of the Zend framework.

Let's say you uploaded the framework to a folder called Zend within your web root.

/www/Zend/

You then need to tell php to use that as your include path like so.

set_include_path($_SERVER['DOCUMENT_ROOT'] . '/Zend/');

From there, you can use the autoLoader function to handle loading of classes from there on out, like so...

require_once 'Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();

Then follow the docs for the GDATA library.....

$service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$spreadsheetService = new Zend_Gdata_Spreadsheets($client);


Take a look at this: http://php.net/manual/en/function.set-include-path.php

set_include_path — Sets the include_path configuration option
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号