Skip to content

slince-archived/oauth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

slince oauth2.0 library

oauth是对oAuth2.0协议的封装支持,如果您对oAuth2.0不了解的话,可以参考http://oauth.net/2/;通过oauth您可以方便的获取登录用户的信息以及服务商提供的其它资料和服务;

##目前支持的服务

  • baidu
  • weibo
  • qq

(后续还在增加中)

使用方式

use Slince\OAuth\Certificate\Certificate;
use Slince\OAuth\ServiceFactory;
use Slince\OAuth\Token\Token;

$certificate = new Certificate(
    client id, 
    client secret, 
    callbackurl
);
$token = new Token();
$baidu = ServiceFactory::get('baidu', $certificate, $token);
if (empty($_GET['code'])) {
	echo $location = $baidu->getAuthorizeUrl();
header("location: {$location}");
} else {
    $token = $baidu->requestToken($_GET['code']);
    echo $token->getAccessToken();
    $token = $baidu->refreshToken($token);
    echo $token->getAccessToken();
    $user = $baidu->request('passport/users/getInfo');
    print_r($user);
} 

详细使用方式请参考demo下的案例

About

oauth2.0协议封装

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages