Php 方法App\Http\Controllers\XeroController::数据不存在
你好,我有XeroAPI 我正在尝试将它与我的laravel项目集成,我得到了上面的错误,我正在使用以下laravel包进行相同的操作 github包链接: ----------------路线----------------- ---控制器-----------------Php 方法App\Http\Controllers\XeroController::数据不存在,php,laravel,xero-api,Php,Laravel,Xero Api,你好,我有XeroAPI 我正在尝试将它与我的laravel项目集成,我得到了上面的错误,我正在使用以下laravel包进行相同的操作 github包链接: ----------------路线----------------- ---控制器----------------- 您的xero/auth/callback路由被路由到不存在的XeroController::data()函数 查看该包,它似乎已经为xero/auth/callback注册了一个路由,指向包中的Authorization
您的xero/auth/callback
路由被路由到不存在的XeroController::data()
函数
查看该包,它似乎已经为xero/auth/callback
注册了一个路由,指向包中的AuthorizationCallbackController
。我假设您只需要删除手动定义的路由。您的xero/auth/callback
路由被路由到XeroController::data()
函数,该函数不存在
查看该包,它似乎已经为xero/auth/callback
注册了一个路由,指向包中的AuthorizationCallbackController
。我假设您只需要删除手动定义的路线。您可以提供code@lagbox是的,我正在共享代码您的xero/auth/callback
路由被路由到XeroController::data()
函数,这是不存在的。你能提供你的code@lagbox是的,我正在共享代码您的xero/auth/callback
路由到XeroController::data()
函数,该函数不存在。
Route::get('/manage/xero', [XeroController::class, 'index'])->name('xero.auth.success');
Route::get('xero/auth/callback', [XeroController::class, 'data'])->name('xero.auth.callback');
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Webfox\Xero\OauthCredentialManager;
class XeroController extends Controller
{
public function index(Request $request, OauthCredentialManager $xeroCredentials)
{
try {
// Check if we've got any stored credentials
if ($xeroCredentials->exists()) {
/*
* We have stored credentials so we can resolve the AccountingApi,
* If we were sure we already had some stored credentials then we could just resolve this through the controller
* But since we use this route for the initial authentication we cannot be sure!
*/
$xero = resolve(\XeroAPI\XeroPHP\Api\AccountingApi::class);
$organisationName = $xero->getOrganisations($xeroCredentials->getTenantId())->getOrganisations()[0]->getName();
$user = $xeroCredentials->getUser();
$username = "{$user['given_name']} {$user['family_name']} ({$user['username']})";
}
} catch (\throwable $e) {
// This can happen if the credentials have been revoked or there is an error with the organisation (e.g. it's expired)
$error = $e->getMessage();
}
return view('xero', [
'connected' => $xeroCredentials->exists(),
'error' => $error ?? null,
'organisationName' => $organisationName ?? null,
'username' => $username ?? null
]);
}
}