// 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();
// Set this to true if you want to see all outgoing requests and responses from server $addback = true; //////////////////////////////// // Login $tmpPath = '/tmp/'; $snapchat = new Snapchat($username, $gEmail, $gPasswd, $debug); $snapchat->login($password); if ($addback == true) { $unconfirmed = $snapchat->getUnconfirmedFriends(); if (!is_null($unconfirmed)) { print_r($unconfirmed); foreach ($unconfirmed as $friend) { $snapchat->addFriendBack($friend); } } } $snaps = $snapchat->getSnaps(); if (!is_null($snaps)) { foreach ($snaps as $snap) { echo "Processing SNAP ID [" . $snap->id . "]<br />"; $snapchat->writeToFile('../src/snaps/' . $snap->id, $snapchat->getMedia($snap->id)); $tmpFilePath = $tmpPath . $snap->id; file_put_contents($tmpFilePath, $snapchat->getMedia($snap->id)); $snapchat->setStory($tmpFilePath, $snap->time); $snapchat->markSnapViewed($snap->id); unlink($tmpFilePath); $snapchat->sendMessage($snap->sender, "Your snap has been processed, and it should appear on this account's story. Thank you for submitting!"); echo "Processed!<br /><br />"; } } $snapchat->closeAppEvent();
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); }
<pre><?php $enabled = false; if (!$enabled) { die; } require_once "snapchat.php"; //////////// CONFIG //////////// $username = ""; // Your snapchat username $password = ""; // Your snapchat password $gEmail = ""; // Gmail account $gPasswd = ""; // Gmail account password $debug = true; // Set this to true if you want to see all outgoing requests and responses from server //////////////////////////////// $img = "../media/logo.png"; // URL or local path to a media file (image or video) $snapchat = new Snapchat($username, $gEmail, $gPasswd, $debug); //Login to Snapchat with your username and password $snapchat->login($password); // Set a story $snapchat->setStory($img); $snapchat->closeAppEvent(); ?> </pre>
//create temp file with the received snap if ($config['moderation'] == false) { postImageStory($filename, mod_id(), $config['username'], $config['password']); } } } } 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
// Set a story // $snapchat->setStory($imagePath); // Set a story adding text to the image and 5 seconds // $snapchat->setStory($imagePath, 5, "This is my turntoi story"); // Automatically downloads Snaps and store it in 'Snaps' folder // Store data received to interpret later on $receivedData = $snapchat->getSnaps(true); print_r($receivedData); // save the senders in an array for ($i = 0; $i < count($receivedData); $i++) { $receivedUsers[$i] = $receivedData[$i]->sender; } print_r($receivedUsers); $dir = "/SC-API/src/"; foreach (glob($dir . "snaps/*/*/*") as $files) { $snapchat->setStory($files, 8); // $snapchat->send($files, "ryan.shane"); echo "{$files} size " . filesize($files) . "\n"; } foreach (glob($dir . "stories/*/*/*") as $files) { // $snapchat->setStory($files, 8); // $snapchat->send($files, "ryan.shane"); echo "{$files} size " . filesize($files) . "\n"; } // Download stories for a specific username $snapchat->getStoriesByUsername("meg_hunt", true); // Send chat message to shane to ensure server is updating $snapchat->sendMessage($sendTo, "Story updated."); // send message to users who submitted snaps to confirm // $snapchat->sendMessage($receivedUsers, "I put your snap up on my story." . $phrases[rand()]); $snapchat->sendMessage($receivedUsers, "I put your snap up on my story.");
<?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->setProxyServer("http://37.187.101.121:3128"); $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->setStory($target_file); echo json_encode(array("SUCCES" => $send)); } else { echo "NOT FOUND"; }