【发布时间】:2016-03-01 04:44:00
【问题描述】:
我正在将谷歌电子表格集成到我的项目中。我必须将表单数据保存到谷歌电子表格中。
为此,我正在使用 asimqt php-google-spreadsheet-client 库。
我在网站上有一个表单,该表单使用 ajax 提交。为此,我在 function.php 中编写了函数。
初始化 DefaultServiceRequest 类的对象时出错。
错误:致命错误:找不到类“Google\Spreadsheet\DefaultServiceRequest”
require '/vendor/autoload.php';
use Google\Spreadsheet\DefaultServiceRequest;
use Google\Spreadsheet\ServiceRequestFactory;
function spreadsheet_feeds()
{
$access_tok = 'xyz-token';
$serviceRequest = new DefaultServiceRequest($access_tok); // Getting error
ServiceRequestFactory::setInstance($serviceRequest);
$spreadsheetService = new Google\Spreadsheet\SpreadsheetService();
$spreadsheetFeed = $spreadsheetService->getSpreadsheets();
}
add_action( 'wp_ajax_nopriv_spreadsheet_data', 'spreadsheet_feeds' );
add_action('wp_ajax_spreadsheet_data','spreadsheet_feeds');
任何帮助为什么会发生此错误,因为类已经包含使用“使用”语句?
【问题讨论】:
-
请粘贴您上传 php-google-spreadsheet-client 库的位置的屏幕截图。
标签: php wordpress google-spreadsheet-api php-5.5