Properties

$DROP_QUERY_PARAMS

$DROP_QUERY_PARAMS

List of query parameters that get automatically dropped when rebuilding the current URL.

$errno

$errno

$errmsg

$errmsg

$isDebug

$isDebug

$boundary

$boundary

$fileinfoDb

$fileinfoDb

Methods

setError()

setError(int  $errno, string  $errmsg) : void

Set the gloable error number and error message.

Parameters

int $errno

Error code

string $errmsg

Error message

errno()

errno() : int

Get the gloable errno.

Returns

int —

errmsg()

errmsg() : string

Get the gloable error message.

Returns

string —

setDebugMode()

setDebugMode(bool  $on = true) : void

Whether to set the debug mode of the Baidu OpenAPI SDK or not.

Parameters

bool $on

true or false

isDebugMode()

isDebugMode() : bool

Whether the debug mode of the Baidu OpenAPI SDK is on or off.

Returns

bool —

request()

request(string  $url, array  $params = array(), string  $httpMethod = 'GET', bool  $multi = false) : string|false

Request for a http/https resource

Parameters

string $url

Url to request

array $params

Parameters for the request

string $httpMethod

Http method, 'GET' or 'POST'

bool $multi

Whether it's a multipart POST request

Returns

string|false —

Returns string if success, or false if failed

errorLog()

errorLog(mixed  $msg) : mixed

Prints to the error log if you aren't in command line mode.

Parameters

mixed $msg

Returns

mixed —

generateSign()

generateSign(array  $params, string  $secret, string  $namespace = 'sign') : string

Generate the signature for passed parameters.

Parameters

array $params

Array of parameters to be signatured

string $secret

Secret key for signature

string $namespace

The parameter which will be excluded when calculate the signature

Returns

string —

Signature of the parameters

getCurrentUrl()

getCurrentUrl() : string

Get the url of current page.

Returns

string —

shouldRetainParam()

shouldRetainParam(mixed  $param) : mixed

Parameters

mixed $param

Returns

mixed —

buildHttpMultipartBody()

buildHttpMultipartBody(array  $params) : string

Build the multipart body for file uploaded request.

Parameters

array $params

Parameters for the request

Returns

string —

detectMimeType()

detectMimeType(mixed  $filename) : string

Tries to detect MIME type of a file

The method will try to use fileinfo extension if it is available, deprecated mime_content_type() function in the other case. If neither works, default 'application/octet-stream' MIME type is returned

Parameters

mixed $filename

Returns

string —

file MIME type