diff --git a/src/snapchat.php b/src/snapchat.php index d8f0ea9..9718ba7 100755 --- a/src/snapchat.php +++ b/src/snapchat.php @@ -133,7 +133,8 @@ public function device() } private function getAttestation($password, $timestamp) { - $nonce = base64_encode(hash('sha256', "$this->username|$password|$timestamp|loq/login", true)); + $hashString = $this->username."|{$password}|{$timestamp}|/loq/login"; + $nonce = base64_encode(hash('sha256', $hashString, true)); $authentication = 'cp4craTcEr82Pdf5j8mwFKyb8FNZbcel'; $apkDigest = 'JJShKOLH4YYjWZlJQ71A2dPTcmxbaMboyfo0nsKYayE'; @@ -340,7 +341,7 @@ public function login($password, $force = FALSE) return $auth; } parent::setGAuth($auth); - $attestation = $this->getAttestation($password, $timestamp); + $attestation = $this->getAttestation($password, $timestamp); $result = parent::post( '/loq/login', @@ -356,7 +357,7 @@ public function login($password, $force = FALSE) 'ptoken' => "ie", 'timestamp' => $timestamp, 'attestation' => $attestation, - 'sflag' => '1', + 'sflag' => 1, 'application_id' => 'com.snapchat.android', 'req_token' => $req_token, ), diff --git a/src/snapchat_agent.php b/src/snapchat_agent.php index 173758c..e1bb4cb 100644 --- a/src/snapchat_agent.php +++ b/src/snapchat_agent.php @@ -395,8 +395,6 @@ public function post($endpoint, $data, $params, $multipart = FALSE, $debug = FAL curl_setopt($ch, CURLOPT_WRITEHEADER, $headerBuff); curl_setopt($ch, CURLOPT_PROXY, $this->proxyServer); $result = curl_exec($ch); - - if(strlen($result) > 0) //make sure curl worked. if not, keep going { if($endpoint == "/loq/login") $result = gzdecode($result); @@ -427,7 +425,7 @@ public function post($endpoint, $data, $params, $multipart = FALSE, $debug = FAL { $jsonResult = json_decode($result); echo 'RESULT: ' . print_r($jsonResult) . "\n"; - if ($jsonResult->status == '-103') + if (property_exists($jsonResult, "status") && $jsonResult->status == '-103') exit(); } else