0

我正在尝试扩展 Laravel\Socialite\Two\AbstractProvider,但我不确定在 Laravel 中执行此操作的最佳/正确方法是什么。阅读文档让我相信我应该在服务提供商那里做这件事。

任何帮助都会很棒,这是我为服务提供商提供的代码:

SocialiteServiceProvider.php

<?php namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class SocialiteServiceProvider extends ServiceProvider  {

    public function register()
    {
        \App::bind('socialize', function()
        {
            echo 'DOESN\'T GET HERE';
            // what do i put here once I do get here
        });
    }
}

然后我有第二个文件

SocialiteAbstractProvider.php

<?php namespace App\Services;

use Laravel\Socialite\Two\AbstractProvider;

abstract class SocialiteAbstractProvider extends AbstractProvider
{
    /**
     * Get the authentication URL for the provider.
     *
     * @param  string  $state
     * @return string
     */
    protected function getAuthUrl($state);


    /**
     * Get the token URL for the provider.
     *
     * @return string
     */
    protected function getTokenUrl();

    /**
     * Get the raw user for the given access token.
     *
     * @param  string  $token
     * @return array
     */
    protected function getUserByToken($token);

    /**
     * Map the raw user array to a Socialite User instance.
     *
     * @param  array  $user
     * @return \Laravel\Socialite\User
     */
    protected function mapUserToObject(array $user);

    public function redirect()
    {
        echo '@s1';
        die;
        $this->request->getSession()->set(
            'state', $state = http_build_query(
                array(
                    'token' => sha1(time().$this->request->getSession()->get('_token')),
                    'domain' => $_SERVER['HTTP_HOST']
                )
            )
        );

        return new RedirectResponse($this->getAuthUrl($state));
    }
}

我也已将其正确添加到我的配置中,因为我能够看到注册事件。

4

0 回答 0