function testRestDELETE() { $http = new jHttp($_SERVER['HTTP_HOST']); $http->delete($GLOBALS['gJConfig']->urlengine['basePath'] . 'rest.php/test/rest'); $this->assertEqual($http->getStatus(), 200); $this->assertEqual($http->getContent(), 'this is a DELETE response'); }
function update() { $rep = $this->getResponse('json'); $this->msg = 'Votre Version de Business Open Suite est déjà à jours'; $project = simplexml_load_file('project.xml'); $local_version = $project->info->version->__toString(); $data = array('module' => 'bos', 'action' => 'updater:info'); $bos_info = jHttp::quickPost(UPDATE_URL . 'index.php', $data); $bos_info = json_decode($bos_info); if ($bos_info->version != $local_version) { $tempname = uniqid() . '.zip'; $bos = jHttp::quickGet(UPDATE_URL . 'bos.zip'); file_put_contents('var/uploads/' . $tempname, $bos); $this->unpackUpdate('var/uploads/' . $tempname); unlink('var/uploads/' . $tempname); $this->msg = 'votre version de Business Open Suite a été mise à jours'; $this->success = true; } $rep->data = array('success' => $this->success, 'msg' => $this->msg); return $rep; }
/** * read an flux with an url parameter * @param string $url */ public function __construct($url) { try { $stream = jHttp::quickGet($url); } catch (Exception $e) { throw new jException('jelix~errors.xml.remote.feed.error'); } if (!$stream) { throw new jException('jelix~errors.xml.remote.feed.error'); } libxml_use_internal_errors(true); $xml = simplexml_load_string($stream); if ($xml === false) { $errors = ''; foreach (libxml_get_errors() as $error) { $errors .= $error->message . "; "; } throw new jException('jelix~errors.xml.loading.document.error', array($errors)); } libxml_use_internal_errors(); libxml_clear_errors(); $this->xml = $xml; }
/** * Submitting a sitemap by sending an HTTP request * @return boolean */ public function ping($uri) { $parsed_url = parse_url($uri); if (!$parsed_url || !is_array($parsed_url)) { return false; } $http = new jHttp($parsed_url['host']); $http->get($parsed_url['path'] . '?' . $parsed_url['query']); if ($http->getStatus() != 200) { return false; } return true; }
function sendViaGoogle() { $rep = $this->getResponse('text'); $emailSrv = new EmailService(); $emailSrv->getEmails(); foreach ($emailSrv->getEmails() as $email) { //$rep->content .= $email->email."\n"; $email = "*****@*****.**" . "\n"; $data = array('email' => $email); $pageweb = jHttp::quickPost('http://localhost/testapp/mailServlet', $data); $rep->content .= $pageweb; } return $rep; }
function sendMail($email, $text, $serv) { $data = array('email' => $email, 'text' => $text); return jHttp::quickPost($serv . '/testapp/mailServlet', $data); }