Methods summary
public static
|
#
initialize( string $appId, string $appKey, string $appMasterKey )
Initialize application key and settings
Initialize application key and settings
Parameters
- $appId
- Application ID
- $appKey
- Application key
- $appMasterKey
- Application master key
|
public static
|
#
setApiTimeout( integer $seconds )
Set a deadline for requests to complete.
Set a deadline for requests to complete.
Note that file upload requests are not affected.
Parameters
|
public static
string
|
#
getVersionString( )
Get version string used as user agent
Get version string used as user agent
Returns
string
|
public static
|
#
useRegion( mixed $region )
Set API region
See LeanCloud\Region for available regions.
Parameters
|
public static
|
|
public static
|
#
setDebug( boolean $flag )
Set debug mode
Enable debug mode to log request params and response.
Parameters
|
public static
|
|
public static
|
#
setServerUrl( string $url )
Set server url
Explicitly set server url with which this client will communicate.
Url shall be in the form of: https://api.leancloud.cn .
Parameters
|
public static
string
|
#
getAPIEndPoint( )
Get API Endpoint
The returned endpoint will include version string.
For example: https://api.leancloud.cn/1.1 .
Returns
string
|
public static
boolean
|
#
verifySign( string $appId, string $sign )
Verify app ID and sign
The sign must be in the format of "{md5sum},{timestamp}[,master]",
which follows the format as in header "X-LC-Sign".
Parameters
- $appId
- App Id
- $sign
- Request sign
Returns
boolean
|
public static
boolean
|
#
verifyKey( string $appId, string $key )
Verify app ID and key
The key shall be in format of "{key}[,master]", it will be verified
as master key if master suffix present.
Parameters
- $appId
- App Id
- $key
- App key or master key
Returns
boolean
|
public static
string
|
#
signHook( string $hookName, integer $msec )
Generate a sign used to auth hook invocation on LeanEngine
Generate a sign used to auth hook invocation on LeanEngine
Parameters
- $hookName
- E.g. "__before_for_Object"
- $msec
- Timestamap in microseconds
Returns
string
|
public static
boolean
|
#
verifyHookSign( string $hookName, string $sign )
Verify a signed hook
Parameters
Returns
boolean
|
public static
array
|
#
request( string $method, string $path, array $data, string $sessionToken = null, array $headers = array(), boolean $useMasterKey = null )
Issue request to LeanCloud
Issue request to LeanCloud
The data is passing in as an associative array, which will be encoded
into JSON if the content-type header is "application/json", or
be appended to url as query string if it's GET request.
The optional headers do have higher precedence, if provided it
will overwrite the items in default headers.
Parameters
- $method
- GET, POST, PUT, DELETE
- $path
- Request path (without version string)
- $data
- Payload data
- $sessionToken
- Session token of a User
- $headers
- Optional headers
- $useMasterKey
- Use master key or not
Returns
array JSON decoded associative array
Throws
RuntimeException, CloudException
|
public static
array
|
#
get( string $path, array $data = null, string $sessionToken = null, array $headers = array(), boolean $useMasterKey = null )
Issue GET request to LeanCloud
Issue GET request to LeanCloud
Parameters
- $path
- Request path (without version string)
- $data
- Payload data
- $sessionToken
- Session token of a User
- $headers
- Optional headers
- $useMasterKey
- Use master key or not
Returns
array JSON decoded associated array
See
self::request()
|
public static
array
|
#
post( string $path, array $data, string $sessionToken = null, array $headers = array(), boolean $useMasterKey = null )
Issue POST request to LeanCloud
Issue POST request to LeanCloud
Parameters
- $path
- Request path (without version string)
- $data
- Payload data
- $sessionToken
- Session token of a User
- $headers
- Optional headers
- $useMasterKey
- Use master key or not, optional
Returns
array JSON decoded associated array
See
self::request()
|
public static
array
|
#
put( string $path, array $data, string $sessionToken = null, array $headers = array(), boolean $useMasterKey = null )
Issue PUT request to LeanCloud
Issue PUT request to LeanCloud
Parameters
- $path
- Request path (without version string)
- $data
- Payload data
- $sessionToken
- Session token of a User
- $headers
- Optional headers
- $useMasterKey
- Use master key or not, optional
Returns
array JSON decoded associated array
See
self::request()
|
public static
array
|
#
delete( string $path, string $sessionToken = null, array $headers = array(), boolean $useMasterKey = null )
Issue DELETE request to LeanCloud
Issue DELETE request to LeanCloud
Parameters
- $path
- Request path (without version string)
- $sessionToken
- Session token of a User
- $headers
- Optional headers
- $useMasterKey
- Use master key or not, optional
Returns
array JSON decoded associated array
See
self::request()
|
public static
array
|
#
batch( array $requests, string $sessionToken = null, array $headers = array(), boolean $useMasterKey = null )
Issue a batch request
Parameters
- $requests
- Array of requests in batch op
- $sessionToken
- Session token of a User
- $headers
- Optional headers
- $useMasterKey
- Use master key or not, optional
Returns
array JSON decoded associated array
See
self::request()
|
public static
mixed
|
#
encode( mixed $value, string $encoder = null, array $seen = array() )
Recursively encode value as JSON representation
Recursively encode value as JSON representation
By default LeanObject will be encoded as pointer, though
$encoder could be provided to encode to customized type, such
as full __type annotated json object. The $encoder must be
name of instance method of object.
To avoid infinite loop in the case of circular object
references, previously seen objects ($seen ) are encoded
in pointer, even a customized encoder was provided.
$obj = new TestObject();
$obj->set("owner", $user);
Client::encode($obj, "toFullJSON");
Client::encode($obj, "toJSON");
Parameters
- $value
- $encoder
- Object encoder name, e.g.: getPointer, toJSON
- $seen
- Array of Object that has been traversed
Returns
mixed
|
public static
string
|
#
formatDate( DateTime $date )
Format date according to LeanCloud spec.
Format date according to LeanCloud spec.
Parameters
Returns
string
|
public static
mixed
|
#
decode( mixed $value, string $key )
Decode value from LeanCloud response.
Decode value from LeanCloud response.
Parameters
- $value
- Value to decode
- $key
- Field key for the value
Returns
mixed
|
public static
LeanCloud\Storage\IStorage
|
|
public static
|
|
public static
float
|
#
randomFloat( float $min = 0, float $max = 1 )
Generate a random float between [$min, $max)
Generate a random float between [$min, $max)
Parameters
Returns
float
|