Example #1
0
function parseCommand($file, $message)
{
    $output = '';
    if (startsWith($message, '/')) {
        $message = substr($message, 1);
        $splits = explode(' ', $message);
        $output = $splits[2];
        switch ($splits[0]) {
            case 'facebook':
                switch ($splits[1]) {
                    case '-user':
                        $analyzer = new FacebookProfiler($splits[2]);
                        $analyzer->analyze();
                        $output = $analyzer->getResponse();
                        break;
                    case '-search':
                        $searcher = new FacebookSearcher($splits[2]);
                        $output = $searcher->getResponse();
                        break;
                }
                break;
            case 'whitespace':
                $name = $splits[1];
                $city = $splits[2];
                $state = $splits[3];
                //$whitepages = new WhitePages('537775405e1660bfb260b59ace642e37');
                break;
        }
        if (strlen($output) > 0) {
            fwrite(fopen($file, 'a'), "<span>Salty Stalker</span>" . '<span class="test">' . ($output = str_replace("\n", " ", $output) . '</span>' . "\n"));
        }
        return true;
    }
    return false;
}
Example #2
0
$channel = 'facebook_scraper';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if ($_POST['token'] == $token) {
        header('content-type: application/json');
        $argument = $_POST['text'];
        $parts = explode(' ', $argument);
        $command = $parts[0];
        $argument = str_replace($command . ' ', '', $argument);
        $output = '';
        switch ($command) {
            case 'search':
                $searcher = new FacebookSearcher($argument);
                $output = $searcher->getStack();
                break;
            case 'user':
                $searcher = new FacebookProfiler($argument);
                $searcher->analyze();
                $output = $searcher->getSlack();
                break;
            default:
                $output = 'Invalid command, please try again.';
                break;
        }
        $response = array('text' => 'The following information was found: ', 'mrkdwn' => 'true', 'attachments' => $output);
        //echo json_encode($response);
        $options = array('http' => array('method' => 'POST', 'content' => json_encode($response), 'header' => "Content-Type: application/json\r\n" . "Accept: application/json\r\n"));
        $context = stream_context_create($options);
        $result = file_get_contents($_POST['response_url'], false, $context);
    }
}
function slack_format($string)