【问题标题】:How can I install Google API client library on server for php without Shell (SSH) access?如何在没有 Shell (SSH) 访问的情况下在服务器上为 php 安装 Google API 客户端库?
【发布时间】:2016-02-06 20:57:16
【问题描述】:

我使用 HostPapa,他们不允许 Shell 访问,只允许 FTP。如何在我的服务器上安装 Google 的 API 客户端库?我也是 git 的菜鸟。我正在尝试遵循本指南...

https://developers.google.com/api-client-library/php/start/installation

但我需要 Composer 或 Shell 访问权限。还有其他方法吗?非常感谢。

编辑:尝试一些东西。我将库上传到我的工作目录。

set_include_path(get_include_path() . PATH_SEPARATOR . '/google-api-php-client-1.1.7/src');
require 'Google/autoload.php';
require 'Google/Client.php';
// my code...

当我尝试运行我的 php 脚本时,我得到了

<b>Warning</b>:  require(Google/autoload.php): failed to open stream: No such file or directory in <b>/path/to/my/script.php</b> on line <b>37</b><br />
   <br />
   <b>Warning</b>:  require(Google/autoload.php): failed to open stream: No such file or directory in <b>/path/to/my/script.php</b> on line <b>37</b><br />
   <br />
   <b>Fatal error</b>:  require(): Failed opening required 'Google/autoload.php' (include_path='.:/usr/lib/php:/usr/local/lib/php:/google-api-php-client-1.1.7/src') in <b>/path/to/my/script.php</b> on line <b>37</b><br />

编辑:K,我搞砸了……应该是……

set_include_path(get_include_path() . PATH_SEPARATOR . 'google-api-php-client-1.1.7/src');
require 'Google/autoload.php';
require 'Google/Client.php';
// my code...

我必须在我的相对路径的开头取出“/”。

【问题讨论】:

    标签: php git shell ftp google-api-php-client


    【解决方案1】:
    1. 从以下地址下载已发布的版本:https://github.com/google/google-api-php-client/releases
    2. 设置包含路径:set_include_path(get_include_path() . PATH_SEPARATOR . 'your/path/to/src');
    3. 现在包含自动加载器文件:require 'Google/autoload.php';
    4. 您的任务: 需要“谷歌/Client.php”; // 你的东西

    【讨论】:

    • 谢谢。我正在尝试您的解决方案。你能看到我上面的编辑吗?看起来对吗?有没有简单的方法来测试它是否有效?
    • 它醒了。起初我放的是 '/your/path/to/src' 而不是 'your/path/to/src'。哎呀。您的解决方案是最简单的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-10
    • 1970-01-01
    • 2015-03-20
    • 2015-05-31
    • 1970-01-01
    相关资源
    最近更新 更多