Example #1
1
// 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();
Example #2
1
// 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.");
$snapchat->clearFeed();
$snapchat->closeAppEvent();
Example #3
1
// 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();