This is inspired by laravel/socialite, you can easily use it without Laravel.
It possible to use it with various frameworks and middleware.
It is compatible with laravel/socialite.
You can check the Document of laravel.
- github
- bitbucket
- Line
- VKontakte
- Weixin
- Twitch
- Slack
- Discord
- Dropbox
- Yahoo
- Spotify
- GitLab
- Yandex
- Add more...
PHP >= 7.0
composer require socialite-manager/socialite
$config = [
'client_id' => 'xxx',
'client_secret' => 'xxx',
'redirect' => 'http://example.com/callback.php',
];
oath.php
use Socialite\Socialite;
Socialite::driver('twitter', $config)->redirect();
callback.php
use Socialite\Socialite;
$user = Socialite::driver('twitter', $config)->user();
$user->getAvatar();
$user->getEmail();
$user->getId();
$user->getNickname();
$user->getName();
Sosialite
have options for use with framework and middleware
Interface: \Psr\Http\Message\ServerRequestInterface
Socialite::driver('twitter', $config)
->setRequest($this->request);
need one of the following read/write
interfaces.
write |
---|
$session->put() |
$session->set() |
$session->write() |
read |
---|
$session->get() |
$session->read() |
Socialite::driver('twitter', $config)
->setSession($this->request->getSession());
Psr\Http\Message\ResponseInterface
will be returned
Socialite::driver('twitter', $config)->psr7Redirect()