Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

serveur / api.php @ 910a6d60

Historique | Voir | Annoter | Télécharger (2,43 ko)

1
<?php
2
/** **********************************************************************************
3
 *
4
 *  Projet ClicAlbum  - Licence: GNU/Affero GPL v3 ou +
5
 *
6
 *  (c) 2020 Éric Seigne <eric.seigne@cap-rel.fr>
7
 *
8
 *   This file is part of ClicAlbum.
9
 *
10
 *   ClicAlbum is free software: you can redistribute it and/or modify
11
 *   it under the terms of the GNU General Public License as published by
12
 *   the Free Software Foundation, either version 3 of the License, or
13
 *   (at your option) any later version.
14
 *
15
 *   ClicAlbum is distributed in the hope that it will be useful,
16
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 *   GNU General Public License for more details.
19
 *
20
 *   You should have received a copy of the GNU General Public License
21
 *   along with ClicAlbum. If not, see <https://www.gnu.org/licenses/>.
22
 *
23
 * ***********************************************************************************/
24

    
25
require_once("tools.php");
26

    
27
/* *****
28
 *
29
 * récupère des informations générales
30
 * exemple liste des serveurs disponibles
31
 *
32
 */
33

    
34
if (strtoupper($_SERVER['REQUEST_METHOD']) != 'POST') {
35
    $arr = array(
36
        'APIversion' => 2,
37
        'APPversion' => "1.0.7",
38
        'servers' => array(
39
            array(
40
                'name' => 'AbulEdu-FR', 'uri' => 'clicalbum.abuledu.net', 'label' => "Association AbulEdu-FR.org : documents conservés 24 h (plus pour l'instant durant la phase de tests) - réservé aux enseignants et élèves (soutenez l'association par un don ou une adhésion, voir www.abuledu-fr.org)"
41
            ),
42
            // array(
43
            //     'name' => 'Informatique Libre', 'uri' => 'clicpdf.informatique-libre.com', 'label' => 'Société Informatique-Libre.com : rétention 4 h - public et gratuit'
44
            // ),
45
        ),
46
        'date' => date("Ymd")
47
    );
48
} else {
49
    $arr = array(
50
        'APIversion' => 2,
51
        'date' => date("Ymd")
52
    );
53
    $body = file_get_contents("php://input");
54

    
55
    myDebug($body);
56

    
57
    // Decode the JSON object
58
    $object = json_decode($body, true);
59

    
60
    // Throw an exception if decoding failed
61
    if (!is_array($object)) {
62
        throw new Exception('Failed to decode JSON object');
63
    }
64

    
65
    if($object['command'] == "createUser") {
66
        $arr = apiCreateUser($object);
67
    }
68
    else if($object['command'] == "createAlbum") {
69
        $arr = apiCreateAlbum($object);
70
    }
71
}
72

    
73
echo json_encode($arr);
Redmine Appliance - Powered by TurnKey Linux