resetDb(); $this->securityToken = BasicSecurityToken::createFromValues(1, 1, 1, 'partuza', 'test.com', 1, 0)->toSerialForm(); $this->securityToken = urldecode($this->securityToken); $this->restUrl = 'http://localhost' . Config::get('web_prefix') . '/social/rest'; } protected function curlRest($url, $postData, $contentType = 'application/json', $method = 'POST') { $_SERVER['CONTENT_TYPE'] = $contentType; $sep = strpos($url, '?') !== false ? '&' : '?'; $_SERVER["REQUEST_URI"] = $this->restUrl . $url . $sep . 'st=' . $this->securityToken; $parsedUrl = parse_url($_SERVER["REQUEST_URI"]); $GLOBALS['HTTP_RAW_POST_DATA'] = $postData ? $postData : null; $_SERVER['REQUEST_METHOD'] = $method; $_SERVER['QUERY_STRING'] = $parsedUrl['query']; $_SERVER['HTTP_HOST'] = $parsedUrl['host']; $_GET = array('st' => $this->securityToken); $servlet = new DataServiceServlet(); $servletMethod = 'do' . ucfirst(strtolower($method)); $servlet->noHeaders = true; // prevents "modify header information" errors ob_start(); $servlet->$servletMethod(); $ret = ob_get_clean(); //var_dump($ret); return $ret; } protected function getSecurityToken() { return $this->securityToken; } protected function setSecurityToken($token) { $this->securityToken = $token; } protected function getRestUrl() { return $this->restUrl; } protected function setRestUrl($url) { $this->restUrl = $url; } }