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();
 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.');
 }
Example #3
0
<?php

define("IN_STORYBOT", 1);
require_once "src/snapchat.php";
require_once "config/config.php";
$snapchat = new Snapchat($config['username'], $config['password']);
//create new instance of class Snapchat
$snaps = $snapchat->getSnaps();
//get feed
$snaps = json_decode(json_encode($snaps), true);
//turn into php array
$i = 0;
foreach ($snaps as $item) {
    if ($item['status'] == 1) {
        //if unopened
        if ($item['sender'] != $config['username']) {
            //if not sent from yourself
            if (!is_banned($item['sender'])) {
                $snapchat->addFriend($item['sender']);
                //add sender as friend if not already
                if ($item['media_type'] == 0) {
                    //if still image
                    if ($config['picturesallowed']) {
                        $data = $snapchat->getMedia($item['id']);
                        //get received snap
                        if ($data != "") {
                            $filename = time() . '__' . $item['sender'] . '.jpg';
                            file_put_contents('media/temp/' . $filename, $data);
                            //create temp file with the received snap
                            if ($config['moderation'] == false) {
                                postImageStory($filename, mod_id(), $config['username'], $config['password']);
Example #4
0
//must use for first login!
//$snapchat->login($password);
// $snapchat->addFriend("wmorgenlander");
// Get 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, "turn sloich", 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 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");