Subversion Repositories Applications.wikini

Compare Revisions

Regard whitespace Rev 32 → Rev 33

/trunk/api/rest/modules/0.5/Service.php
6,19 → 6,9
 
protected function formaterEnJsonp($donnees = null, $encodage = 'utf-8') {
$contenu = $_GET['callback'].'('.json_encode($donnees).');';
return $this->preparerEnvoie($contenu, 'text/html', $encodage);
return $contenu;
}
protected function formaterEnJson($donnees = null, $encodage = 'utf-8') {
$contenu = json_encode($donnees);
return $this->preparerEnvoie($contenu, 'application/json', $encodage);
}
private function preparerEnvoie($sortie = 'OK', $mime = 'text/html', $encodage = 'utf-8') {
$this->envoyerEnteteContenu($encodage, $mime);
return $sortie;
}
 
private function envoyerEnteteContenu($encodage, $mime) {
if (!is_null($mime) && !is_null($encodage)) {
header("Content-Type: $mime; charset=$encodage");
27,6 → 17,13
}
}
public function envoyerContenuJson($donnees = null, $encodage = 'utf-8') {
$contenu = json_encode($donnees);
$this->envoyerEnteteContenu($encodage, 'application/json');
echo $contenu;
exit;
}
protected function envoyerAuth($message_accueil, $message_echec) {
header('HTTP/1.0 401 Unauthorized');
header('WWW-Authenticate: Basic realm="'.mb_convert_encoding($message_accueil, 'ISO-8859-1', 'UTF-8').'"');
34,5 → 31,10
print $message_echec;
exit(0);
}
protected function envoyerErreur($e) {
header($e->getCode());
echo $e->getMessage();
}
}
?>