我使用OAuth 2.0流+ google-api-php-client + Mybusiness PHP类,但出现“找不到类”错误,请参见下文:
use App\Vendors\Google_Service_MyBusiness as MyBusiness;
....
$gClient->setAccessToken($access_token);
$oauth2 = new \Google_Service_Oauth2($gClient);
$userInfo = $oauth2->userinfo->get();
print_r($userInfo); //Works!
$mybusinessService = new MyBusiness($gClient);
//return Class 'Google_Service_MyBusiness_Location' not found:
$mybusinessService->accounts->get('accounts/xxxxxxxx');
//return 'Google_Service_MyBusiness_ListAccountsResponse' not found:
$accounts = $mybusinessService->accounts;
$accountsList = $accounts->listAccounts()->getAccounts();
完整错误:
Class 'Google_Service_MyBusiness_Account' not found in file /vendor/google/apiclient/src/Google/Http/REST.php on line 128
MyBusiness类已自动加载:
"autoload" : {
"files": [
"app/Vendors/MyBusiness.php"
]
}
所有必填项(例如Google_Service_MyBusiness_ListAccountsResponse
,Google_Service_MyBusiness_Location
在app/Vendors/MyBusiness.php
中)
我的代码有什么问题?
答案 0 :(得分:0)
在功能listAccounts()的第1262行更改
来自:
123456
收件人:
parent
答案 1 :(得分:0)
供应商目录不在App/Vendor
内。
尝试这样
$service = new \Google_Service_MyBusiness($client);