Skip to content

Commit ba5767b

Browse files
committed
More minor adjustments
1 parent 80c2652 commit ba5767b

File tree

1 file changed

+34
-27
lines changed

1 file changed

+34
-27
lines changed

src/snapchat.php

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,9 @@ public function register($username, $password, $email, $birthday) {
364364
/**
365365
* Retrieves general user, friend, and snap updates.
366366
*
367-
* @param $stories (optional) Retrieve story updates. Defaults to false.
367+
* @todo Add separate story function.
368+
*
369+
* @param $stories (optional) Whether to retrieve story updates. Defaults to FALSE.
368370
* @return The data returned by the service or FALSE on failure.
369371
*/
370372
public function getUpdates($stories = FALSE) {
@@ -386,16 +388,17 @@ public function getUpdates($stories = FALSE) {
386388
)
387389
);
388390

389-
if($stories) {
390-
if (!empty($result->stories_response)) {
391+
if ($stories) {
392+
if (!empty($result->stories_response)) {
391393
return $result->stories_response;
392394
}
393-
} else if (!empty($result->updates_response)) {
395+
}
396+
elseif (!empty($result->updates_response)) {
394397
$this->auth_token = $result->updates_response->auth_token;
395398
return $result->updates_response;
396399
}
397400

398-
return $result;
401+
return $result;
399402
}
400403

401404

@@ -1036,29 +1039,35 @@ public function getStoryThumb($media_id, $key, $iv) {
10361039
* @returns TRUE on success or FALSE on failure.
10371040
*/
10381041
public function markStoryViewed($id, $screenshot_count = 0) {
1039-
// Make sure we're logged in and have a valid access token.
1042+
// Make sure we're logged in and have a valid access token.
10401043
if (!$this->auth_token || !$this->username) {
10411044
return FALSE;
1045+
}
1046+
1047+
// Mark story as viewed.
1048+
$timestamp = self::timestamp();
1049+
$result = self::post(
1050+
'/update_stories',
1051+
array(
1052+
'friend_stories' => json_encode(array(
1053+
array(
1054+
'id' => $id,
1055+
'screenshot_count' => $screenshot_count,
1056+
'timestamp' => $timestamp,
1057+
),
1058+
)),
1059+
'timestamp' => $timestamp,
1060+
'username' => $this->username,
1061+
),
1062+
array(
1063+
$this->auth_token,
1064+
$timestamp,
1065+
)
1066+
);
1067+
1068+
return is_null($result);
10421069
}
1043-
1044-
// Mark story as viewed.
1045-
$timestamp = self::timestamp();
1046-
$result = self::post(
1047-
'/update_stories',
1048-
array(
1049-
'friend_stories' => '[{"id":"'.$id.'","screenshot_count":'.$screenshot_count.',"timestamp":'.$timestamp.'}]',
1050-
'timestamp' => $timestamp,
1051-
'username' => $this->username,
1052-
),
1053-
array(
1054-
$this->auth_token,
1055-
$timestamp,
1056-
)
1057-
);
1058-
1059-
return is_null($result);
1060-
}
1061-
1070+
10621071

10631072
/**
10641073
* Gets the best friends and scores of the specified users.
@@ -1189,5 +1198,3 @@ public function updateEmail($email) {
11891198
}
11901199

11911200
}
1192-
1193-
?>

0 commit comments

Comments
 (0)