1. Go to this page and download the library: Download saeedvir/socialite-slim 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/ */
saeedvir / socialite-slim example snippets
use Saeedvir\SocialiteSlim\Socialite;
// Redirect user to OAuth provider
return Socialite::driver('google')->redirect();
// Get user information from provider callback
$user = Socialite::driver('google')->user();
// Get specific user data
$user->getId();
$user->getNickname();
$user->getName();
$user->getEmail();
$user->getAvatar();
use Saeedvir\SocialiteSlim\Facades\OAuth;
// Find or create an OAuth connected user
$oauthUser = OAuth::findOrCreateOauthUser(
'google',
$user->getId(),
[
'access_token' => $user->token,
'refresh_token' => $user->refreshToken,
'expires_in' => $user->expiresIn,
'name' => $user->name,
'email' => $user->email,
'avatar' => $user->avatar
]
);
// Check if user has OAuth connection
$hasConnection = OAuth::userHasOauthConnection($userModel, 'google');
// Get OAuth user by provider and ID
$storedOauthUser = OAuth::getOauthUser('google', $googleUserId);
use Saeedvir\SocialiteSlim\Socialite;
use Saeedvir\SocialiteSlim\Testing\SocialiteFake;
// In your tests:
Socialite::fake();
// Define a fake user for GitHub
Socialite::fake('github', (object) [
'id' => '12345',
'nickname' => 'githubuser',
'name' => 'GitHub User',
'email' => '[email protected]',
]);
// Now Socialite::driver('github')->user() will return the fake user above