PHP Class BaiduUtils, thinksns

Author: zhujianting([email protected])
Exibir arquivo Open project: medz/thinksns-4 Class Usage Examples

Protected Properties

Property Type Description
$DROP_QUERY_PARAMS List of query parameters that get automatically dropped when rebuilding the current URL.

Public Methods

Method Description
errmsg ( ) : string Get the gloable error message.
errno ( ) : integer Get the gloable errno.
errorLog ( $msg ) Prints to the error log if you aren't in command line mode.
generateSign ( array $params, string $secret, string $namespace = 'sign' ) : string Generate the signature for passed parameters.
getCurrentUrl ( ) : string Get the url of current page.
isDebugMode ( ) : boolean Whether the debug mode of the Baidu OpenAPI SDK is on or off.
request ( string $url, array $params = [], string $httpMethod = 'GET', boolean $multi = false ) : string | false Request for a http/https resource
setDebugMode ( boolean $on = true ) Whether to set the debug mode of the Baidu OpenAPI SDK or not.
setError ( integer $errno, string $errmsg ) Set the gloable error number and error message.

Private Methods

Method Description
buildHttpMultipartBody ( array $params ) : string Build the multipart body for file uploaded request.
detectMimeType ( $filename ) : string Tries to detect MIME type of a file
shouldRetainParam ( $param )

Method Details

errmsg() public static method

Get the gloable error message.
public static errmsg ( ) : string
return string

errno() public static method

Get the gloable errno.
public static errno ( ) : integer
return integer

errorLog() public static method

Prints to the error log if you aren't in command line mode.
public static errorLog ( $msg )

generateSign() public static method

Generate the signature for passed parameters.
public static generateSign ( array $params, string $secret, string $namespace = 'sign' ) : string
$params array Array of parameters to be signatured
$secret string Secret key for signature
$namespace string The parameter which will be excluded when calculate the signature
return string Signature of the parameters

getCurrentUrl() public static method

Get the url of current page.
public static getCurrentUrl ( ) : string
return string

isDebugMode() public static method

Whether the debug mode of the Baidu OpenAPI SDK is on or off.
public static isDebugMode ( ) : boolean
return boolean

request() public static method

Request for a http/https resource
public static request ( string $url, array $params = [], string $httpMethod = 'GET', boolean $multi = false ) : string | false
$url string Url to request
$params array Parameters for the request
$httpMethod string Http method, 'GET' or 'POST'
$multi boolean Whether it's a multipart POST request
return string | false Returns string if success, or false if failed

setDebugMode() public static method

Whether to set the debug mode of the Baidu OpenAPI SDK or not.
public static setDebugMode ( boolean $on = true )
$on boolean true or false

setError() public static method

Set the gloable error number and error message.
public static setError ( integer $errno, string $errmsg )
$errno integer Error code
$errmsg string Error message

Property Details

$DROP_QUERY_PARAMS protected_oe static_oe property

List of query parameters that get automatically dropped when rebuilding the current URL.
protected static $DROP_QUERY_PARAMS