farzak / socialite
OAuth 1 & OAuth 2 libraries.
v1.0.3
2020-06-20 15:26 UTC
Requires
- php: >=7.0.0
- guzzlehttp/guzzle: ^6.0
- league/oauth1-client: ^1.0
- symfony/http-foundation: ^3.0
- zendframework/zend-diactoros: ^1.7
Requires (Dev)
- phpstan/phpstan: ^0.9.2
- phpunit/phpunit: ^6.0
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2025-03-21 02:12:50 UTC
README
Introduction
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.
Core Providers
- github
- bitbucket
other Providers
- Line
- VKontakte
- Weixin
- Twitch
- Slack
- Discord
- Dropbox
- Yahoo
- Spotify
- GitLab
- Yandex
- Add more...
Requirement
PHP >= 7.0
Installation
composer require socialite-manager/socialite
Basic Usage
$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();
Advanced Usage
Sosialite
have options for use with framework and middleware
Set Request
Interface: \Psr\Http\Message\ServerRequestInterface
Socialite::driver('twitter', $config) ->setRequest($this->request);
Set Session
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());
Redirect psr7 response
Psr\Http\Message\ResponseInterface
will be returned
Socialite::driver('twitter', $config)->psr7Redirect()