コード例 #1
0
 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.');
 }
コード例 #2
0
ファイル: config.php プロジェクト: Artea/storybot
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);
}
コード例 #3
0
ファイル: bot.php プロジェクト: Artea/storybot
             $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']);
             }
         }
     }
 } 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
 }