Properties

$BD_OAUTH2_ENDPOINTS

$BD_OAUTH2_ENDPOINTS

Endpoints for Baidu OAuth2.0.

$clientId

$clientId

$clientSecret

$clientSecret

$redirectUri

$redirectUri

Methods

__construct()

__construct(string  $clientId = '', string  $clientSecret = '') : mixed

Constructor

Parameters

string $clientId

Client_id of the baidu thirdparty app or access_key of the developer.

string $clientSecret

Client_secret of the baidu thirdparty app or secret_key of the developer.

Returns

mixed —

setRedirectUri()

setRedirectUri( $redirectUri) : \BaiduOAuth2

Set the redirect uri for the app.

Parameters

$redirectUri

Where to redirect after user authorization.

Returns

\BaiduOAuth2 —

getRedirectUri()

getRedirectUri() : string

Get the redirect uri for the app.

Returns

string —

getClientId()

getClientId() : mixed

Returns

mixed —

getLogoutUrl()

getLogoutUrl(string  $accessToken, string  $next = '') : string

Get a Logout URL suitable for use with redirects.

Parameters

string $accessToken

Access token for current user

string $next

Url to go to after a successful logout

Returns

string —

The URL for the logout flow

getAuthorizeUrl()

getAuthorizeUrl(string  $responseType = 'code', string  $scope = '', string  $state = '', string  $display = 'popup') : string

Get baidu oauth2's authorization granting url.

Parameters

string $responseType

Response type, 'code' or 'token'

string $scope

blank space separated list of requested extended perms

string $state

state parameter

string $display

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

Returns

string —

Page url for authorization granting

getAccessTokenByAuthorizationCode()

getAccessTokenByAuthorizationCode(string  $code) : array|false

Get access token ifno by authorization code.

Parameters

string $code

Authorization code

Returns

array|false —

returns access token info if success, or false if failed

getAccessTokenByClientCredentials()

getAccessTokenByClientCredentials(string  $scope = '') : array|false

Get access token info by client credentials.

Parameters

string $scope

Extend permissions delimited by blank space

Returns

array|false —

returns access token info if success, or false if failed.

getAccessTokenByDeveloperCredentials()

getAccessTokenByDeveloperCredentials(string  $accessKey, string  $secretKey) : array|false

Get access token info by developer credentials

Parameters

string $accessKey

Access key you got from baidu cloud platform

string $secretKey

Secret key you got from baidu cloud platform

Returns

array|false —

Returns access token info if success, or false if failed

getAccessTokenByRefreshToken()

getAccessTokenByRefreshToken(string  $refreshToken, string  $scope = '') : array|false

Refresh access token by refresh token.

Parameters

string $refreshToken

The refresh token

string $scope

Extend permissions delimited by blank space

Returns

array|false —

returns access token info if success, or false if failed.

makeAccessTokenRequest()

makeAccessTokenRequest(array  $params) : mixed

Make an oauth access token request

The parameters:

  • client_id: The client identifier, just use api key
  • response_type: 'token' or 'code'
  • redirect_uri: the url to go to after a successful login
  • scope: The scope of the access request expressed as a list of space-delimited, case sensitive strings.
  • state: An opaque value used by the client to maintain state between the request and callback.
  • display: login page style, 'page', 'popup', 'touch' or 'mobile'

Parameters

array $params

oauth request parameters

Returns

mixed —

returns access token info if success, or false if failed

getLoggedInUser()

getLoggedInUser(mixed  $access_token) : mixed

Parameters

mixed $access_token

Returns

mixed —