public function main() { $this->app = new Slim(); $app = $this->app; $this->app->any("/slack", function () use($app) { $post = $_REQUEST; $response = $app->response(); $response['Content-Type'] = 'application/json'; $response->status(200); if ($post['token'] !== "hG235FjlUjsg5CVDybDcGphW") { $response->body(json_encode(array('text' => 'Invalid Token'))); return; } $command = $post['text']; $matches = explode(" ", $command); $sendingUser = $post['user_name']; if (count($matches) !== 3) { $response->body(json_encode(array('text' => 'Invalid Usage'))); return; } $username = $this->_getReceivingUser($app->request); $action = $this->_getAction($app->request); if (!isset($this->_users[$username])) { $user = new User(); $user->setUsername($username); $this->_users[$username] = $user; } if (!isset($this->_users[$sendingUser])) { $user = new User(); $user->setUsername($sendingUser); $this->_users[$sendingUser] = $user; } if (method_exists($this, $action)) { $message = $this->{$action}($app->request); $response->body(json_encode(array('text' => $message))); return; } $response->body(json_encode(array('text' => 'Invalid Usage'))); }); //$this->help(); //$this->aggrigateData(); $this->app->run(); }