Skip to content

Commit 7ea9d1c

Browse files
committed
Add a check for a compressed snap data
Snap data is compressed when a video is sent with an overlay (text, drawings or filters) - Check for compression - unCompress - Return both files as an array with keys (overlay, and m4v).
1 parent c5eb944 commit 7ea9d1c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/snapchat.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,11 @@ public function unblock($username) {
665665
*
666666
* @return mixed
667667
* The snap data or FALSE on failure.
668+
* Snap data can returned as an Array of more than one file.
669+
* @return: Array (
670+
* overlay => binary_file_content,
671+
* M4V =>binary_m4v_content
672+
* )
668673
*/
669674
public function getMedia($id) {
670675
// Make sure we're logged in and have a valid access token.
@@ -695,6 +700,18 @@ public function getMedia($id) {
695700
if (parent::isMedia(substr($result, 0, 2))) {
696701
return $result;
697702
}
703+
704+
//When a snapchat video is sent with "text" or overlay
705+
//the overlay is a transparent PNG file PKZIPPED together
706+
//with the M4V file.
707+
//First two bytes "PK" x50x4B; thus the previous will
708+
//fail and would've returned "FALSE".
709+
if (parent::isCompressed(substr($result, 0, 2))) {
710+
//Uncompress
711+
@result_array = parent::unCompress($result);
712+
//Return Media and Overlay
713+
return @result_array;
714+
}
698715
}
699716

700717
return FALSE;

0 commit comments

Comments
 (0)