Свойство | Тип | Описание | |
---|---|---|---|
$BD_OPENAPI_DEFAULT_DOMAINS | Scheme & domain for Baidu OpenAPI interfaces. | ||
$BD_OPENAPI_DEFAULT_PREFIXS | URL prefixs for Baidu OpenAPI interfaces. |
Свойство | Тип | Описание | |
---|---|---|---|
$accessToken | |||
$batchMode | integer | Mode of batch/run api | |
$batchQueue | array | Array of api calls to be batch run. | |
$clientId | |||
$finalEncode | Charset of the app pages, default is UTF-8 |
Метод | Описание | |
---|---|---|
__construct ( string $clientId, string $accessToken ) | Constructor | |
api ( string $uri, array $params = [], 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. | |
beginBatch ( ) | Start a batch operation. | |
end_batch ( ) | End current batch operation | |
getAccessToken ( ) : string | Get the access token for the following api calls. | |
getClientId ( ) : string | Get the client_id. | |
getFinalEncode ( ) : string | Get the charset of the app. | |
iconv ( $var, $inCharset = 'UTF-8', $outCharset = 'GBK' ) | ||
setAccessToken ( string $accessToken ) : BaiduApiClient | Set access token for the following api calls. | |
setBatchMode ( integer $batchMode ) : BaiduApiClient | Set the mode of batch/run api. | |
setClientId ( string $clientId ) : BaiduApiClient | Set the client_id. | |
setFinalEncode ( string $finalEncode ) : BaiduApiClient | Set the charset for the app. | |
upload ( string $uri, $params = [] ) : Returns | Call a file upload api. |
Метод | Описание | |
---|---|---|
batchRun ( ) | ||
converJson2Array ( $json ) | ||
doBatchRun ( $useHttps = true ) |
public __construct ( string $clientId, string $accessToken ) | ||
$clientId | string | Client_id of the baidu thirdparty app or access_key of the developer. |
$accessToken | string | Access token for api call. |
public api ( string $uri, array $params = [], string $httpMethod = 'GET', string $type = 'rest' ) : array | false | ||
$uri | string | 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'. |
$params | array | Api specific parameters. |
$httpMethod | string | Http method, could be 'GET' or 'POST'. |
$type | string | Type name of the openapi, could be 'rest', or 'public'. |
Результат | array | false | Returns an array if success, or false if failed. |
public getAccessToken ( ) : string | ||
Результат | string |
public getFinalEncode ( ) : string | ||
Результат | string |
public static iconv ( $var, $inCharset = 'UTF-8', $outCharset = 'GBK' ) |
public setAccessToken ( string $accessToken ) : BaiduApiClient | ||
$accessToken | string | |
Результат | BaiduApiClient |
public setBatchMode ( integer $batchMode ) : BaiduApiClient | ||
$batchMode | integer | Use BaiduApiClient::BATCH_MODE_SERVER_PARALLEL or BaiduApiClient::BATCH_MODE_SERIAL_ONLY |
Результат | BaiduApiClient |
public setClientId ( string $clientId ) : BaiduApiClient | ||
$clientId | string | Client_id of the baidu thirdparty app or access_key of the developer. |
Результат | BaiduApiClient |
public setFinalEncode ( string $finalEncode ) : BaiduApiClient | ||
$finalEncode | string | 'UTF-8' or 'GBK' |
Результат | BaiduApiClient |
public upload ( string $uri, $params = [] ) : Returns | ||
$uri | string | 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 | an array if success, or false if failed. |
public static $BD_OPENAPI_DEFAULT_DOMAINS |
public static $BD_OPENAPI_DEFAULT_PREFIXS |
protected array $batchQueue | ||
Результат | array |