简体   繁体   English

如何在共享主机方案中使用PHP的Google Docs API?

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

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. 我想在Google电子表格中读写特定的单元格,但我对互联网上有关如何操作的大量信息感到困惑。 I only have access to shared hosting (which means an FTP access and a control panel), not a virtual server. 我只能访问共享主机(这意味着FTP访问和控制面板),而不是虚拟服务器。

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. 在Google Docs官方API页面中,它仅在版本1中支持PHP,并且已经弃用了它,并且它已经在版本3中,因此我不应该开始使用它。

On this page: http://code.google.com/apis/gdata/docs/client-libraries.html it says that the PHP client library is 在此页面上: http//code.google.com/apis/gdata/docs/client-libraries.html它说PHP客户端库是

Distributed as part of zend. 作为zend的一部分分发。

while on this page: http://code.google.com/apis/gdata/articles/php_client_lib.html it says 在此页面上: http//code.google.com/apis/gdata/articles/php_client_lib.html它说

The client library is part of the open-source Zend Framework but can also be downloaded as a standalone version. 客户端库是开源Zend Framework的一部分,但也可以作为独立版本下载。

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. 我最大的问题是我从未使用过Zend,我不知道如何使用它或如何安装/更新它的包。 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 a 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: 我从这个页面下载了最新版本: http//framework.zend.com/download/gdata并在其INSTALL文件中说:

Zend Framework requires no special installation steps. Zend Framework不需要特殊的安装步骤。 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. 只需下载框架,将其解压缩到您希望保留的文件夹中,然后将库目录添加到PHP include_path中。 To use components in the extras library, add the extras/library directory to your PHP include_path, as well. 要使用extras库中的组件,还要将extras / library目录添加到PHP include_path中。 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. 如果您想使用Zend_Tool,只需将bin / zf.bat(对于Windows)或bin / zf.sh(对于其他任何内容)添加到系统可执行路径。

I think include_path means some variable in php.ini, not something what I have access to. 我认为include_path意味着php.ini中的一些变量,而不是我有权访问的内容。 Can I just simply download/extract zend to my folder and do include_once() at a start of my code? 我可以简单地下载/解压缩到我的文件夹,并在我的代码的开头做include_once()吗?

You will want to contact your hosting provider to see if they have the Zend framework installed. 您需要联系您的托管服务提供商,看看他们是否安装了Zend框架。 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. 如果没有,您可以下载该库,解压缩并将其上传到您的Web根目录。

The GDATA module is part of the Zend framework. GDATA模块是Zend框架的一部分。

Let's say you uploaded the framework to a folder called Zend within your web root. 假设您将框架上传到Web根目录中名为Zend的文件夹中。

/www/Zend/ /网络/的Zend /

You then need to tell php to use that as your include path like so. 然后你需要告诉php使用它作为你的包含路径。

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... 从那里,您可以使用autoLoader函数来处理从那里开始的类的加载,就像这样......

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

Then follow the docs for the GDATA library..... 然后按照GDATA库的文档.....

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

看看这个: http//php.net/manual/en/function.set-include-path.php

set_include_path — Sets the include_path configuration option

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM