// Casper API Key $casperSecret = ""; // Casper API Secret $debug = false; // Set this to true if you want to see all outgoing requests and responses from server //////////////////////////////// $imagePath = ""; // URL or local path to a media file (image or video) $sendTo = array(); $snapchat = new Snapchat($username, $gEmail, $gPasswd, $casperKey, $casperSecret, $debug); //Login to Snapchat with your username and password $snapchat->login($password); // Get your friends in an array $friends = $snapchat->getFriends(); echo "My friends: "; print_r($friends); // Send snap adding text to your image and 10 seconds $snapchat->send($imagePath, $sendTo, "this is a test :D", 10); // Set a story // $snapchat->setStory($imagePath); // Set a story adding text to the image and 5 seconds $snapchat->setStory($imagePath, 5, "This is my story"); // Get snaps data (Without storing them) //$snapchat->getSnaps(); // Automatically downloads Snaps and store it in 'Snaps' folder $snapchat->getSnaps(true); // Download stories for a specific username $snapchat->getStoriesByUsername("homie", true); // Send chat message to "username" $snapchat->sendMessage("username", "hello from Snap-API!"); $snapchat->closeAppEvent();
private function _sendAndReceive($file, $type) { $snapchat = new Snapchat($this->users[1]['name'], $this->users[1]['pass']); $this->assertNotEquals($snapchat->auth_token, FALSE, 'Login failed for test user 1.'); $id = $snapchat->upload($type, file_get_contents($file)); $this->assertEquals(is_string($id), TRUE, ($type == Snapchat::MEDIA_IMAGE ? 'Image' : 'Video') . ' upload failed.'); $result = $snapchat->send($id, array($this->users[2]['name'])); $this->assertEquals($result, TRUE, 'Media send failed.'); // TODO $this->assertEquals($snapchat->clearFeed(), TRUE, 'Failed to clear the feed of test user 1.'); $this->assertEquals($snapchat->logout(), TRUE, 'Logout failed for test user 1.'); $snapchat = new Snapchat($this->users[2]['name'], $this->users[2]['pass']); $this->assertNotEquals($snapchat->auth_token, FALSE, 'Login failed for test user 2.'); $snaps = $snapchat->getSnaps(); $this->assertNotEquals($snaps, FALSE, 'Failed to get snap list.'); foreach ($snaps as $snap) { if ($snap->status == Snapchat::STATUS_DELIVERED && strcmp($snap->recipient, $snapchat->username) == 0) { $data = $snapchat->getMedia($snap->id); $this->assertEquals($snapchat->markSnapViewed($snap->id), TRUE, 'User 2 marked snap viewed.'); $this->assertEquals($snapchat->markSnapShot($snap->id), TRUE, 'User 2 marked screenshot.'); $this->assertEquals(is_string($data), TRUE); } } $this->assertEquals($snapchat->clearFeed(), TRUE, 'Failed to clear the feed of test user 2.'); $this->assertEquals($snapchat->logout(), TRUE, 'Logout failed for test user 2.'); }
function postImageStory($file, $mod_id, $username, $password) { $snapchat = new Snapchat($username, $password); //create new instance of class Snapchat $id = $snapchat->upload(Snapchat::MEDIA_IMAGE, file_get_contents('media/temp/' . $file)); //upload the temp to story $snapchat->setStory($id, Snapchat::MEDIA_IMAGE); //set story $id = $snapchat->upload(Snapchat::MEDIA_IMAGE, file_get_contents('media/accept.jpg')); //send verification snap $exploded = explode("__", $file); $exploded = explode(".", $exploded[1]); $snapchat->send($id, array($exploded[0]), 10); //10 seconds long rename("media/temp/" . $file, "media/archive/" . $file); //move temp to archive $imagelog = file_get_contents("log/imagelog"); $imagelog .= "MOD: " . $mod_id . " - FILE: " . $file . " - TIME: " . time(); $imagelog .= PHP_EOL; file_put_contents("log/imagelog", $imagelog); $count = intval(file_get_contents("log/count")); $count++; file_put_contents("log/count", $count); }
<?php header("Content-Type:text/json"); require "src/snapchat.php"; if ($_POST['token'] === "1234567demo") { $username = $_POST['username']; // Your snapchat username $password = $_POST['password']; // Your snapchat password $gEmail = $_POST['gMail']; // Gmail account $gPasswd = $_POST['gPasswd']; // Gmail account password $debug = false; // Set this to true if you want to see all outgoing requests and responses from server $casperKey = "4232cf886ff2d2c1747d40adfab409f0"; // Casper API Key $casperSecret = "b47a666ce0fefb90de058a8a38f01ff2"; // Casper API Secret $snapchat = new Snapchat($username, $gEmail, $gPasswd, $casperKey, $casperSecret, $debug); $snapchat->login($password); $target_dir = "uploads/"; $target_file = $target_dir . basename($_FILES["Video"]["name"]); if (move_uploaded_file($_FILES["Video"]["tmp_name"], $target_file)) { } $send = $snapchat->send($target_file, $_POST['to'], "", $_POST['time']); echo json_encode(array("SUCCES" => $send)); } else { echo "NOT FOUND"; }
<?php header("Content-Type:text/plain"); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(-1); require "src/snapchat.php"; $username = "******"; // Your snapchat username $password = "******"; // Your snapchat password $gEmail = "*****@*****.**"; // Gmail account $gPasswd = "123456cat"; // Gmail account password $debug = true; // Set this to true if you want to see all outgoing requests and responses from server $snapchat = new Snapchat($username, $gEmail, $gPasswd, $debug); //Login to Snapchat with your username and password $snapchat->login($password); $send = $snapchat->send("1.mov", "banana.apps99", "", 5); //$snapchat->addFriend("banana.apps99"); print_r($send); echo "Good";
} elseif ($item['media_type'] == 1) { //if moving video if ($config['videosallowed']) { $data = $snapchat->getMedia($item['id']); //get received snap file_put_contents('media/temp.mov', $data); //create temp file with the received sna $id = $snapchat->upload(Snapchat::MEDIA_VIDEO, file_get_contents('media/temp.mov')); //upload the temp to story $snapchat->setStory($id, Snapchat::MEDIA_VIDEO, $config['videotime']); //set story unlink("media/temp.mov"); //delete temp } } $snapchat->markSnapViewed($item['id']); //mark as viewed, just in case if ($config['send_verify_snap']) { $id = $snapchat->upload(Snapchat::MEDIA_IMAGE, file_get_contents('media/thanks.jpg')); //send verification snap $snapchat->send($id, array($item['sender']), 10); //10 seconds long } $i++; //keep going } } } } $snapchat->clearFeed(); //clear feed (will become VERY long VERY soon and break program)