承接 cresjie/social-login 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cresjie/social-login

最新稳定版本:1.0.0.0

Composer 安装命令:

composer require cresjie/social-login

包简介

Laravel authentication with Social Services API

README 文档

README

Laravel 4 Authentication with Social Services API (OAuth2) like Google, Facebook, Yahoo, Github

Installation via Composer

Add this to your composer.json file, in the require object:

 "cresjie/social-login": "v1.0.0.0"

After that, run composer install to install the package.

Add the service provider to app/config/app.php, within the providers array.

 'providers' => array(
	...
	'Cresjie\SocialLogin\SocialLoginServiceProvider'
)

Configuration

Publish the default config file to your application so you can make modifications.

$ php artisan config:publish cresjie/social-login

Add your service provider credentials to the published config file:

 app/config/packages/cresjie/social-login/config.php

for formality set your redirect callback credential to something like: www.mysite.com/login/google/callback see **Basic usage -> Authentication **

BASIC USAGE

##Login Page

Route::get('/login/{provider}',function($provider){
	return SocialLogin::login($provider);
});

where provider is a social service like google, facebook, etc.. this would redirect the user to the login page for the that social service.

##Authentication

Route::get('/login/{provider}/callback',function($provider){
	var_dump( SocialLogin::authenticate($provider) );
});

after the user logs in to his social service. He/she will be redirected to the url specified in your config file redirect, and just call the SocialLogin::authenticate($provider) to retrieve information

Other Usage

you can also filter results in the config file to have uniform calls. For example retrieving profile picture in google has an array key of picture while in github has an array key of avatar_url

Route::get('/login/{provider}/callback',function($provider){
	$results = SocialLogin::authenticate($provider);
	
	echo $results['picture']; // for goole
	echo $results['avatar_url']; //for github
	
});

how about a uniform call.

Route::get('/login/{provider}/callback',function($provider){
	$results = SocialLogin::authenticate($provider);
	
	echo $results['image']; //uniform call
	
});

how? just set filter_result in the config file with something like:

<?php
	return [
		'google' => [
				...
				'filter_result' => function($result){
					$result['image'] = $result['picture'];
					return $result; //should have return value
				}
		],

		'github' => [
			...
			'filter_result' => function($result){
				$result['image'] = $result['avatar_url'];
				return $result;
			}
		]
];

we've just add another key to the result value to have a uniform call.. cool!

Access Token

After the user successfully authenticate the login. You can get the access token by calling the method: SocialLogin::getAccessToken()

统计信息

  • 总下载量: 55
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-02-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固