RestApi.php 2.26 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
// Fake REST API from Campaign module

class RestApi {
    function campaign($f3,$args) {
        echo '{
            "title": "Piphone Demo\'s campaign",
            "description": "This is a demo campaign used to illustrate how the piphone works. This campaign does not grants you the possibility to contact anyone, it\'s just an ilustration of how it works.",
            "start_date": "2014-01-01",
            "end_date": "2014-12-31",
            "default_language": "en"
        }';
    }

    function contacts($f3,$args) {
        // List of contacts
    }

    function contact($f3,$args) {
        if ($f3->exists('PARAMS.contact')) {
            // Specified contact
        } else {
            // Random contact
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
            echo '{
                "id": "4123",
                "last_name": "ANDERSDOTTER",
                "first_name": "Amelia",
                "tel": "+322 28 45922",
                "groups": [
                    {
                        "type": "Political group",
                        "name": "Greens/EFA",
                        "media": ""
                    },
                    {
                        "type": "National party",
                        "name": "Piratpartiet",
                        "media": ""
                    },
                    {
                        "type": "Country",
                        "name": "SE",
                        "media": ""
                    },
                    {
                        "type": "Committee",
                        "name": "ITRE",
                        "media": ""
                    },
                    {
                        "type": "Committee",
                        "name": "INTA",
                        "media": ""
                    },
                    {
                        "type": "Committee",
                        "name": "CONT",
                        "media": ""
                    }
                ]
            }';
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
        }
    }

    function groups($f3,$args) {
        // List of groups available
    }

    function categories($f3,$args) {
        // List of feedback categories
    }

    function feedback_add($f3,$args) {
        // List of contacts
    }

    function arguments($f3,$args) {
        // List of arguments
    }

};