} } protected function users() { if ($this->method == 'POST') { if ($this->verb == 'urls') { $this->urlClass->setUser($this->id); if (property_exists($this->postContent, 'url')) { $this->urlClass->setUrl($this->postContent->url); return $this->urlClass->insert_url(); } else { return array('status' => 500, 'result' => 'The POST data is out of the API standards'); } } else { return array('status' => 404, 'result' => 'Not Found'); } } else { return array('status' => 200, 'result' => 'Only accepts POST requests'); } } } // Requests from the same server don't have a HTTP_ORIGIN header if (!array_key_exists('HTTP_ORIGIN', $_SERVER)) { $_SERVER['HTTP_ORIGIN'] = $_SERVER['SERVER_NAME']; } try { $API = new UrlShortener($_REQUEST['request'], $_SERVER['HTTP_ORIGIN']); echo $API->processAPI(); } catch (Exception $e) { echo json_encode(array('error' => $e->getMessage())); }