Properties

$clientId

$clientId : string

The client_id of the app or access_key of the developer.

Type

string

$clientSecret

$clientSecret : string

The client_secret of the app or secret_key of the developer.

Type

string

$redirectUri

$redirectUri : string

Redirect uri of the app, where we will redirect to after user authorization.

Type

string

$store

$store : \BaiduStore

Storage for the user session related datas, like state, authorization code, access token and so on.

Type

BaiduStore

$state

$state : string

Type

string

$session

$session : array

User session info.

Type

array

Methods

__construct()

__construct(string  $clientId, string  $clientSecret, string  $redirectUri, \BaiduStore  $store = null) : mixed

Constructor

Parameters

string $clientId

The client_id of the app or access_key of the developer.

string $clientSecret

The client_secret of the app or secret_key of the developer.

string $redirectUri

Redirect uri of the app.

\BaiduStore $store

Storage for the user session related datas.

Returns

mixed —

getBaiduOAuth2Service()

getBaiduOAuth2Service() : \BaiduOAuth2

Get an instance of BaiduOAuth2 class.

Returns

\BaiduOAuth2 —

getBaiduApiClientService()

getBaiduApiClientService() : \BaiduApiClient

Get an instance of BaiduApiClient class.

Returns

\BaiduApiClient —

getAccessToken()

getAccessToken() : string|false

Get access token for openapi calls.

Returns

string|false —

Returns access token if user has authorized the app, or false if not.

getRefreshToken()

getRefreshToken() : string|false

Get refresh token.

Returns

string|false —

Returns refresh token if app has, or false if not.

getLoggedInUser()

getLoggedInUser() : \uint|false

Get currently logged in user's uid.

Returns

\uint|false —

Return uid of the loggedin user, or return false if user isn't loggedin.

getLoginUrl()

getLoginUrl(string  $scope = '', string  $display = 'page') : string

Get a Login URL for use with redirects. By default, full page redirect is assumed. If you are using the generated URL with a window.open() call in JavaScript, you can pass in display=popup as part of the $params.

Parameters

string $scope

blank space separated list of requested extended perms

string $display

Authorization page style, 'page', 'popup', 'touch' or 'mobile'

Returns

string —

the URL for the login flow

getLogoutUrl()

getLogoutUrl(string  $next) : string

Get the Logout URL suitable for use with redirects.

Parameters

string $next

Url to go to after a successful logout.

Returns

string —

getSession()

getSession() : array

Get user session info.

Returns

array —

setSession()

setSession(array  $session) : \Baidu

Set user session.

Parameters

array $session

User session info.

Returns

\Baidu —

getUser()

getUser() : array|false

Get current user's uid and uname.

Returns

array|false —

array('uid' => xx, 'uname' => xx)

setStore()

setStore(\BaiduStore  $store) : \Baidu

Set the session data storage instance.

Parameters

\BaiduStore $store

Returns

\Baidu —

doGetSession()

doGetSession() : array|false

Get session info from Baidu server or from the store in app server side.

Returns

array|false —

getCode()

getCode() : mixed

Get the authorization code from the query parameters, if it exists, otherwise return false to signal no authorization code was discoverable.

Returns

mixed —

Returns the authorization code, or false if the authorization code could not be determined.

establishCSRFTokenState()

establishCSRFTokenState() : void

Lays down a CSRF state token for this process.