PHP Class OAuth, thinksns

Datei anzeigen Open project: medz/thinksns-4 Class Usage Examples

Public Properties

Property Type Description
$client_id
$client_secret

Public Methods

Method Description
checkOAuthValid ( ) 验证授权是否有效
clearOAuthInfo ( ) 清除授权
getAccessToken ( $code, $redirect_uri ) : string 获取请求token的url
getAuthorizeURL ( $redirect_uri, $response_type = 'code', $wap = false ) : string 获取授权URL
init ( $client_id, $client_secret ) 初始化
refreshToken ( ) 刷新授权信息 此处以SESSION形式存储做演示,实际使用场景请做相应的修改

Method Details

checkOAuthValid() public static method

验证授权是否有效
public static checkOAuthValid ( )

clearOAuthInfo() public static method

清除授权
public static clearOAuthInfo ( )

getAccessToken() public static method

获取请求token的url
public static getAccessToken ( $code, $redirect_uri ) : string
$code 调用authorize时返回的code
$redirect_uri 回调地址,必须和请求code时的redirect_uri一致
return string

getAuthorizeURL() public static method

获取授权URL
public static getAuthorizeURL ( $redirect_uri, $response_type = 'code', $wap = false ) : string
$redirect_uri 授权成功后的回调地址,即第三方应用的url
$response_type 授权类型,为code
$wap 用于指定手机授权页的版本,默认PC,值为1时跳到wap1.0的授权页,为2时同理
return string

init() public static method

初始化
public static init ( $client_id, $client_secret )
$client_id 即 appid
$client_secret 即 appkey

refreshToken() public static method

刷新授权信息 此处以SESSION形式存储做演示,实际使用场景请做相应的修改
public static refreshToken ( )

Property Details

$client_id public_oe static_oe property

public static $client_id

$client_secret public_oe static_oe property

public static $client_secret