PHP Class SnapchatAgent

ファイルを表示 Open project: jorgenphi/php-snapchat Class Usage Examples

Public Properties

Property Type Description
$CURL_OPTIONS Default cURL options. It doesn't appear that the UA matters, but authenticity, right?

Public Methods

Method Description
decryptCBC ( data $data, string $key, string $iv ) : data Decrypts blob data for stories.
decryptECB ( data $data ) : data Decrypts blob data for standard images and videos.
encryptECB ( data $data ) : data Encrypts blob data for standard images and videos.
get ( string $endpoint ) : data Performs a GET request. Currently only used for story blobs.
hash ( string $first, string $second ) : string Implementation of Snapchat's hashing algorithm.
isCompressed ( data $data ) : boolean Checks to see if a blob looks like a compressed file.
isMedia ( data $data ) : boolean Checks to see if a blob looks like a media file.
pad ( data $data, integer $blocksize = 16 ) : data Pads data using PKCS5.
post ( string $endpoint, array $data, array $params, boolean $multipart = FALSE ) : mixed Performs a POST request. Used for pretty much everything.
timestamp ( ) : integer Returns the current timestamp.
unCompress ( data $data ) : array Uncompress the blob and put the data into an Array.

Method Details

decryptCBC() public method

Decrypts blob data for stories.
public decryptCBC ( data $data, string $key, string $iv ) : data
$data data The data to decrypt.
$key string The base64-encoded key.
$iv string $iv The base64-encoded IV.
return data The decrypted data.

decryptECB() public method

Decrypts blob data for standard images and videos.
public decryptECB ( data $data ) : data
$data data The data to decrypt.
return data The decrypted data.

encryptECB() public method

Encrypts blob data for standard images and videos.
public encryptECB ( data $data ) : data
$data data The data to encrypt.
return data The encrypted data.

get() public method

Performs a GET request. Currently only used for story blobs.
public get ( string $endpoint ) : data
$endpoint string The address of the resource being requested (e.g. '/story_blob' or '/story_thumbnail').
return data The retrieved data.

hash() public method

Implementation of Snapchat's hashing algorithm.
public hash ( string $first, string $second ) : string
$first string The first value to use in the hash.
$second string The second value to use in the hash.
return string The generated hash.

isCompressed() public method

Checks to see if a blob looks like a compressed file.
public isCompressed ( data $data ) : boolean
$data data The blob data (or just the header).
return boolean TRUE if the blob looks like a compressed file, FALSE otherwise.

isMedia() public method

Checks to see if a blob looks like a media file.
public isMedia ( data $data ) : boolean
$data data The blob data (or just the header).
return boolean TRUE if the blob looks like a media file, FALSE otherwise.

pad() public method

Pads data using PKCS5.
public pad ( data $data, integer $blocksize = 16 ) : data
$data data The data to be padded.
$blocksize integer The block size to pad to. Defaults to 16.
return data The padded data.

post() public method

Performs a POST request. Used for pretty much everything.
public post ( string $endpoint, array $data, array $params, boolean $multipart = FALSE ) : mixed
$endpoint string The address of the resource being requested (e.g. '/update_snaps' or '/friend').
$data array An dictionary of values to send to the API. A request token is added automatically.
$params array An array containing the parameters used to generate the request token.
$multipart boolean If TRUE, sends the request as multipart/form-data. Defaults to FALSE.
return mixed The data returned from the API (decoded if JSON). Returns FALSE if the request failed.

timestamp() public method

Returns the current timestamp.
public timestamp ( ) : integer
return integer The current timestamp, expressed in milliseconds since epoch.

unCompress() public method

Array( overlay~zip-CE6F660A-4A9F-4BD6-8183-245C9C75B8A0 => overlay_file_data, media~zip-CE6F660A-4A9F-4BD6-8183-245C9C75B8A0 => m4v_file_data )
public unCompress ( data $data ) : array
$data data The blob data (or just the header).
return array Array containing both file contents, or FALSE if couldn't extract.

Property Details

$CURL_OPTIONS public_oe static_oe property

Default cURL options. It doesn't appear that the UA matters, but authenticity, right?
public static $CURL_OPTIONS