找不到类"Google_Service_Docs"(Google Docs API quickstart.php) [英] Class 'Google_Service_Docs' not found (Google Docs API quickstart.php)

查看:103
本文介绍了找不到类"Google_Service_Docs"(Google Docs API quickstart.php)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在按照本指南进行授权我的网站可以访问Google Docs API,但是我无法通过第4步.

I am following this guide to authorize access of my website to the Google Docs API but I am having trouble getting through step 4.

当我按照步骤4在SSH命令行中运行此命令时:

When I run this command in the SSH command line as per step 4 the guide:

$ php quickstart.php

在命令行中什么也没有发生,尽管我在工作目录中有一个错误日志,并且出现以下内容:

nothing happens within the command line, although I have an error log in the working directory and the following appears:

[08-Feb-2019 09:47:23 America/New_York]
PHP Fatal error:  Uncaught Error: Class 'Google_Service_Docs' not found in /home/***/***/composer/quickstart.php:12
Stack trace:
#0 /home/***/***/composer/quickstart.php(62): getClient()
#1 {main}
thrown in /home/***/***/composer/quickstart.php on line 12

作为参考,代码中的第12行(您可以完整查看

For reference, line 12 in the code (which you can view in full in the official Google guide) is line 5 in the code below:

function getClient()
{
    $client = new Google_Client();
    $client->setApplicationName('Google Docs API PHP Quickstart');
    $client->setScopes(Google_Service_Docs::DOCUMENTS_READONLY);
    $client->setAuthConfig('credentials.json');
    $client->setAccessType('offline');
...

我之前已经成功安装了Sheets API,所以在步骤1或2中应该不会有任何问题,而步骤3只是复制粘贴,所以我不知道问题到底在哪里.

I have already successfully installed the Sheets API before so there shouldn't be any problem in steps 1 or 2, and step 3 is just copy-paste so I have no idea where the problem could be on my end.

推荐答案

$client->setScopes(Google_Service_Docs::DOCUMENTS_READONLY);

^似乎已过时,并且该指南不是最新的,请改用此方法:

^ Seems to be obsolete and the guide is not up to date, use this instead:

$client->setScopes(https://www.googleapis.com/auth/documents);

这篇关于找不到类"Google_Service_Docs"(Google Docs API quickstart.php)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆