Skip to content
This repository has been archived by the owner on Dec 16, 2020. It is now read-only.

Commit

Permalink
uploading/sending changes. mime now based on data
Browse files Browse the repository at this point in the history
  • Loading branch information
teknogeek committed Aug 16, 2015
1 parent 1fc5a0e commit ea09880
Showing 1 changed file with 28 additions and 23 deletions.
51 changes: 28 additions & 23 deletions src/snapchat.php
Original file line number Diff line number Diff line change
Expand Up @@ -2017,7 +2017,7 @@ public function updateUser($acceptSnapCashV2Tos = true, $acceptSnapCashTos = tru
* @return mixed
* The ID of the uploaded media or FALSE on failure.
*/
public function upload($data, $media)
public function upload($data)
{
// Make sure we're logged in and have a valid access token.
if(!$this->auth_token || !$this->username)
Expand All @@ -2026,7 +2026,7 @@ public function upload($data, $media)
}

$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $media);
$mime = finfo_buffer($finfo, $data);

if(strstr($mime, "video/"))
{
Expand All @@ -2038,6 +2038,7 @@ public function upload($data, $media)
}
else
{
echo "\nBad file type, must be a photo or video.\n";
return false;
}

Expand Down Expand Up @@ -2159,29 +2160,33 @@ public function send($media, $recipients, $text = null, $time = 3)
$mediaData = file_get_contents($media);
}

$media_id = $this->upload($mediaData, $media);
$media_id = $this->upload($mediaData);

$timestamp = parent::timestamp();
$result = parent::post(
'/loq/send',
array(
'media_id' => $media_id,
'zipped' => '0',
'recipients' => $recipients,
'username' => $this->username,
'time' => $time,
'timestamp' => $timestamp,
'features_map' => '{}'
),
array(
$this->auth_token,
$timestamp
),
$multipart = false,
$debug = $this->debug
);
if($media_id)
{
$timestamp = parent::timestamp();
$result = parent::post(
'/loq/send',
array(
'media_id' => $media_id,
'zipped' => '0',
'recipients' => $recipients,
'username' => $this->username,
'time' => $time,
'timestamp' => $timestamp,
'features_map' => '{}'
),
array(
$this->auth_token,
$timestamp
),
$multipart = false,
$debug = $this->debug
);
return $result;
}

return $result;
return $media_id;
}

/**
Expand Down

0 comments on commit ea09880

Please sign in to comment.