Php Oriceon OAuth Laravel 5-调用未定义的方法OAuth::consumer()

Php Oriceon OAuth Laravel 5-调用未定义的方法OAuth::consumer(),php,laravel,api,oauth,Php,Laravel,Api,Oauth,我正在为Laravel 5实现OAuth服务提供商 我收到这个错误“调用未定义的方法OAuth::consumer()”。 我按照自述文件的步骤进行安装: 我在composer.json中添加了“oriceon/oauth-5-laravel”:“dev master”。然后我运行composer update,没有错误 我已将“Artdarek\OAuth\OAuthServiceProvider::class”添加到“providers”数组app.php中 我已经在app.php中的“别

我正在为Laravel 5实现OAuth服务提供商

我收到这个错误“调用未定义的方法OAuth::consumer()”。 我按照自述文件的步骤进行安装:

  • 我在composer.json中添加了“oriceon/oauth-5-laravel”:“dev master”。然后我运行composer update,没有错误

  • 我已将“Artdarek\OAuth\OAuthServiceProvider::class”添加到“providers”数组app.php中

  • 我已经在app.php中的“别名”数组中添加了“'OAuth'=>Artdarek\OAuth\Facade\OAuth::class”

以下是我的config/oauth-5-laravel.php:

return [

    /*
    |--------------------------------------------------------------------------
    | oAuth Config
    |--------------------------------------------------------------------------
    */

    /**
     * Storage
     */
    'storage' => '\\OAuth\\Common\\Storage\\Session',

    /**
     * Consumers
     */
    'consumers' => [

        'Facebook' => [
            'client_id'     => '',
            'client_secret' => '',
            'scope'         => [],
        ],

        'Google' => [
            'client_id'     => env('GOOGLE_CLIENT_ID'),
            'client_secret' => env('GOOGLE_SECRET_ID'),
            'scope'         => ['userinfo_email', 'userinfo_profile'],
        ],

    ]

];
这是我的GoogleController.php:

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use OAuth;

class GoogleController extends Controller
{

    public function loginWithGoogle(Request $request)
    {
        // get data from request
        $code = $request->get('code');

        // get google service
        $googleService = \OAuth::consumer('Google');

        // check if code is valid

        // if code is provided get user data and sign in
        if ( ! is_null($code))
        {
            // This was a callback request from google, get the token
            $token = $googleService->requestAccessToken($code);

            // Send a request with it
            $result = json_decode($googleService->request('https://www.googleapis.com/oauth2/v1/userinfo'), true);

            $message = 'Your unique Google user id is: ' . $result['id'] . ' and your name is ' . $result['name'];
            echo $message. "<br/>";

            //Var_dump
            //display whole array.
            dd($result);
        }
        // if not ask for permission first
        else
        {
            // get googleService authorization
            $url = $googleService->getAuthorizationUri();

            // return to google login url
            return redirect((string)$url);
        }
    }
}
namespace-App\Http\Controllers;
使用\Http\Request;
使用OAuth;
类GoogleController扩展控制器
{
使用Google的公共函数登录(请求$Request)
{
//从请求中获取数据
$code=$request->get('code');
//获取谷歌服务
$googleService=\OAuth::消费者('Google');
//检查代码是否有效
//如果提供了代码,请获取用户数据并登录
如果(!为null($code))
{
//这是一个来自谷歌的回调请求,获取令牌
$token=$googleService->requestAccessToken($code);
//发送一个请求
$result=json_decode($googleService->request($result)https://www.googleapis.com/oauth2/v1/userinfo",对),;
$message='您的唯一谷歌用户id是:'。$result['id'.',您的名字是'.$result['name'];
回显$message。“
”; //瓦鲁垃圾场 //显示整个阵列。 dd(结果); } //如果没有,请先请求许可 其他的 { //获取谷歌服务授权 $url=$googleService->getAuthorizationUri(); //返回google登录url 返回重定向((字符串)$url); } } }
问题在于php中的类OAuth是在oriceons OAuth之后被取消的。

问题在于php中的类OAuth是在oriceons OAuth之后被取消的