Created
November 27, 2013 13:12
-
-
Save ThePengwin/7675407 to your computer and use it in GitHub Desktop.
A quick as hell snapchat bot i hacked tigether with a nice little library from dstelljes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //snapchat lib from here | |
| //https://github.com/dstelljes/php-snapchat/blob/master/src/snapchat.php | |
| include ('lib/snapchat.php'); | |
| include ('config.php'); | |
| $snapchat = new Snapchat(); | |
| $snapchat->login(SNAPCHAT_USER,SNAPCHAT_PASSWORD); | |
| $replypayload = null; | |
| $payload_sender = ''; | |
| $wait = 10; | |
| echo 'starting loop'."\r\n"; | |
| while ( true ) { | |
| echo 'Getting Snaps....'."\r\n"; | |
| $feed = $snapchat->getSnaps(); | |
| echo 'Got ' . count ($feed) . 'results'."\r\n"; | |
| if (count ($feed) > 0) { | |
| echo 'Clearing Feed.'."\r\n"; | |
| $snapchat->clearFeed(); | |
| } | |
| if (!is_array($feed)) { | |
| echo 'Crap! feed not array!'."\r\n"; | |
| var_dump($feed); | |
| continue; | |
| } | |
| foreach ($feed as $snap) { | |
| //if im the sender i dont care | |
| if ($snap->sender == $snapchat->username) continue; | |
| switch ($snap->media_type) { | |
| case (Snapchat::MEDIA_FRIEND_REQUEST): | |
| //add the friend back | |
| echo 'Accepting friend:'.$snap->sender."\r\n"; | |
| $res = $snapchat->addFriend($snap->sender); | |
| break; | |
| case ( Snapchat::MEDIA_IMAGE) : | |
| case ( Snapchat::MEDIA_VIDEO) : | |
| case ( Snapchat::MEDIA_VIDEO_NOAUDIO) : | |
| case ( Snapchat::MEDIA_FRIEND_REQUEST_IMAGE) : | |
| case ( Snapchat::MEDIA_FRIEND_REQUEST_VIDEO) : | |
| case ( Snapchat::MEDIA_FRIEND_REQUEST_VIDEO_NOAUDIO) : | |
| $data = $snapchat->getMedia($snap->id); | |
| if ($data === false) { | |
| echo 'Get Failed!'."\r\n"; | |
| } else { | |
| echo 'Snap obtained! Marking viewed.'."\r\n"; | |
| $snapchat->markSnapViewed($snap->id); | |
| if ($snap->media_type == Snapchat::MEDIA_IMAGE || $snap->media_type == Snapchat::MEDIA_FRIEND_REQUEST_IMAGE ) | |
| $reptype = Snapchat::MEDIA_IMAGE; | |
| if ($snap->media_type == Snapchat::MEDIA_VIDEO || $snap->media_type == Snapchat::MEDIA_FRIEND_REQUEST_VIDEO ) | |
| $reptype = Snapchat::MEDIA_VIDEO; | |
| if ($snap->media_type == Snapchat::MEDIA_VIDEO_NOAUDIO || $snap->media_type == Snapchat::MEDIA_FRIEND_REQUEST_VIDEO_NOAUDIO ) | |
| $reptype = Snapchat::MEDIA_VIDEO_NOAUDIO; | |
| if (!is_null($replypayload)) { | |
| echo 'Sending '.$payload_sender.'\'s snap to '.$snap->sender."\r\n"; | |
| $snapchat->send($replypayload, array($snap->sender), 10); | |
| $replypayload = null; | |
| } | |
| echo 'Storing new payload from '.$snap->sender."\r\n"; | |
| $replypayload = $snapchat->upload( | |
| $reptype,$data | |
| ); | |
| echo 'Stored as '.$replypayload."\r\n"; | |
| $payload_sender = $snap->sender; | |
| } | |
| break; | |
| } | |
| echo 'Snap ID:'.$snap->id . ' Processed!'."\r\n"; | |
| } | |
| echo 'Will check again in '.$wait.' secs....'; | |
| sleep ($wait); | |
| echo 'K Go!'."\r\n"; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Whats in config.php?