PHP code example of redsnapper / socialite-swissrx
1. Go to this page and download the library: Download redsnapper/socialite-swissrx 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/ */
redsnapper / socialite-swissrx example snippets
//Providers\EventServiceProvider.php
use RedSnapper\SwissRx\SwissRxExtendSocialite;
use SocialiteProviders\Manager\SocialiteWasCalled;
protected $listen = [
//...
SocialiteWasCalled::class => [
SwissRXExtendSocialite::class
],
];
//config\services.php
//...
'swissrx' => [
'client_id' => env('SWISS_RX_KEY'),
'client_secret' => env('SWISS_RX_SECRET'),
'redirect' => config('app.url') . "/swiss-rx/callback",
'token_leeway' => env('SWISS_RX_TOKEN_LEEWAY'), // optional - you can use this if you are getting 'Cannot handle token prior to...' exceptions
],
//Http\Controllers\LoginController.php
use Laravel\Socialite\Facades\Socialite;
public function redirectToProvider()
{
return Socialite::driver('swissrx')->with([
'lang' => request()->get('lang', 'en')
])->redirect();
}
public function handleProviderCallback()
{
$swissRxUser = Socialite::driver('swissrx')->user();
retunr $swissRxUser;
}
public function redirectToProvider()
{
return Socialite::driver('swissrx')->with([
'lang' => request()->get('lang', 'en')
])
->setScopes(['personal'])
->redirect();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.