1. Go to this page and download the library: Download ichinya/laravel-socialite library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Infrastructure\Auth;
use Closure;
use Ichinya\LaravelSocialite\Contracts\RedirectHook;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Response;
use Symfony\Component\HttpFoundation\RedirectResponse as SymfonyRedirectResponse;
class TelegramRedirectScreen implements RedirectHook
{
public function handle(
string $driver,
mixed $provider,
Closure $fallback,
): RedirectResponse|Response|SymfonyRedirectResponse|string|null {
if ($driver !== 'telegram' || !method_exists($provider, 'getButton')) {
return null;
}
return response('<html>custom wrapper screen</html>');
}
}
use Illuminate\Support\Facades\Event;
use SocialiteProviders\Manager\SocialiteWasCalled;
use SocialiteProviders\Telegram\Provider as TelegramProvider;
Event::listen(function (SocialiteWasCalled $event): void {
$event->extendSocialite('telegram', TelegramProvider::class);
});
use Ichinya\LaravelSocialite\Traits\HasSocialites;
class User extends Authenticatable
{
use HasSocialites;
}