nf/social
Composer 安装命令:
composer require nf/social
包简介
Social login provider
README 文档
README
It's an extension for our theme https://github.com/hieu-pv/nf-theme
Installation
Step 1: Install Through Composer
composer require nf/social
Step 2: Add the Service Provider
Open
config/app.phpand register the required service provider.
'providers' => [ // .... Others providers \NightFury\Social\SocialServiceProvider::class, ],
Step 3: Create a callback url
Create a new page and use shortcode [nf_social_oauth_callback], then use url of the page as callback url with one more query param ?provider={your_provider}
For example we have a page with url is https://{your_domain}/oauth then we use
https://{your_domain}/oauth?provider=facebookfor Facebook apphttps://{your_domain}/oauth?provider=twitterfor Twitter apphttps://{your_domain}/oauth?provider=googlefor Google app
Step 4: Update your config file config/app.php with CLIENT_ID and SECRET_KEY
<?php return [ // Other config 'services' => [ 'facebook' => [ 'client_id' => 'your_facebook_app_client_id', 'client_secret' => 'your_facebook_app_secret_key', 'redirect' => 'https://{your_domain}/oauth?provider=facebook', // use callback url from step 3 ], 'twitter' => [ 'client_id' => 'your_twitter_app_client_id', 'client_secret' => 'your_twitter_app_secret_key', 'redirect' => 'https://{your_domain}/oauth?provider=twitter', // use callback url from step 3 ], 'google' => [ 'client_id' => '', 'client_secret' => '', 'redirect' => '', ], ], ]
Step 5: Show login urls
We have a shortcode to render login urls [nf_social_url providers]
[nf_social_url providers="facebook,twitter"]
use it anywhere that you want to display login button
Or you can generate login url for each provider
$facebook_login_url = \NightFury\Social\Facades\Social::driver('facebook')->stateless()->redirect()->getTargetUrl(); $google_login_url = \NightFury\Social\Facades\Social::driver('google')->stateless()->redirect()->getTargetUrl(); $twitter_login_url = \NightFury\Social\Facades\Social::driver('twitter')->redirect()->getTargetUrl();
统计信息
- 总下载量: 72
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-12-07