Constants

BATCH_MODE_SERVER_PARALLEL

BATCH_MODE_SERVER_PARALLEL = 0

BATCH_MODE_SERIAL_ONLY

BATCH_MODE_SERIAL_ONLY = 1

Properties

$BD_OPENAPI_DEFAULT_DOMAINS

$BD_OPENAPI_DEFAULT_DOMAINS

Scheme & domain for Baidu OpenAPI interfaces.

$BD_OPENAPI_DEFAULT_PREFIXS

$BD_OPENAPI_DEFAULT_PREFIXS

URL prefixs for Baidu OpenAPI interfaces.

$clientId

$clientId

$accessToken

$accessToken

$finalEncode

$finalEncode

Charset of the app pages, default is UTF-8

$batchMode

$batchMode : int

Mode of batch/run api

Type

int

$batchQueue

$batchQueue : array

Array of api calls to be batch run.

Type

array

Methods

__construct()

__construct(string  $clientId, string  $accessToken) : mixed

Constructor

Parameters

string $clientId

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

string $accessToken

Access token for api call.

Returns

mixed —

getClientId()

getClientId() : string

Get the client_id.

Returns

string —

setClientId()

setClientId(string  $clientId) : \BaiduApiClient

Set the client_id.

Parameters

string $clientId

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

Returns

\BaiduApiClient —

getAccessToken()

getAccessToken() : string

Get the access token for the following api calls.

Returns

string —

setAccessToken()

setAccessToken(string  $accessToken) : \BaiduApiClient

Set access token for the following api calls.

Parameters

string $accessToken

Returns

\BaiduApiClient —

getFinalEncode()

getFinalEncode() : string

Get the charset of the app.

Returns

string —

setFinalEncode()

setFinalEncode(string  $finalEncode) : \BaiduApiClient

Set the charset for the app.

Parameters

string $finalEncode

'UTF-8' or 'GBK'

Returns

\BaiduApiClient —

setBatchMode()

setBatchMode(int  $batchMode) : \BaiduApiClient

Set the mode of batch/run api.

Parameters

int $batchMode

Use BaiduApiClient::BATCH_MODE_SERVER_PARALLEL or BaiduApiClient::BATCH_MODE_SERIAL_ONLY

Returns

\BaiduApiClient —

beginBatch()

beginBatch() : mixed

Start a batch operation.

Returns

mixed —

end_batch()

end_batch() : mixed

End current batch operation

Returns

mixed —

api()

& api(string  $uri, array  $params = array(), string  $httpMethod = 'GET', string  $type = 'rest') : array|false

Call an api which is opened by Baidu, file upload apis should not be called by this interface.

Parameters

string $uri

Uri for the api, it could be the whole url, like 'https://openapi.baidu.com/rest/2.0/passport/user/info/get', or url path only, like '/rest/2.0/passport/user/info/get', or just api method only, like 'passport/user/info/get'.

array $params

Api specific parameters.

string $httpMethod

Http method, could be 'GET' or 'POST'.

string $type

Type name of the openapi, could be 'rest', or 'public'.

Returns

array|false —

Returns an array if success, or false if failed.

upload()

upload(string  $uri,  $params = array()) : \Returns

Call a file upload api.

Parameters

string $uri

Uri for the api, it could be the whole url, like 'https://openapi.baidu.com/file/2.0/cloudalbum/picture/upload', or just api method only, like 'cloudalbum/picture/upload', if the api is provided under the domain of openapi.baidu.com.

$params

Api specific parameters.

Returns

\Returns —

an array if success, or false if failed.

iconv()

iconv(mixed  $var, mixed  $inCharset = 'UTF-8', mixed  $outCharset = 'GBK') : mixed

Parameters

mixed $var
mixed $inCharset
mixed $outCharset

Returns

mixed —

batchRun()

batchRun() : mixed

Returns

mixed —

doBatchRun()

doBatchRun(mixed  $useHttps = true) : mixed

Parameters

mixed $useHttps

Returns

mixed —

converJson2Array()

converJson2Array(mixed  $json) : mixed

Parameters

mixed $json

Returns

mixed —