RestApi.php 1.1 KB
Newer Older
1
<?php
2 3 4 5 6
/*
 * Fake REST API from Campaign module
 *
 * Uses datas folder to retrieve informations
 */
7 8

class RestApi {
9 10 11 12 13 14 15
    function return_datas($filename) {
        $f = fopen($filename, 'r');
        $result = fread($f, filesize($filename));
        fclose($f);
        return $result;
    }

16
    function campaign($f3,$args) {
17
        echo $this->return_datas('app/datas/campaign.json');
18 19 20
    }

    function contacts($f3,$args) {
21
        echo $this->return_datas('app/datas/contacts.json');
22 23
    }

24 25 26 27 28 29 30 31 32 33
    function contact($f3,$args) {
	$contacts = json_decode($this->return_datas('app/datas/contacts.json', true));
	foreach($contacts as $contact) {
		if ( $contact->id == $args['cid'] ) {
			echo json_encode($contact);
			return;
		}
	};
    }

34 35
    function categories($f3,$args) {
        // List of feedback categories
nepski's avatar
nepski committed
36 37 38 39 40 41
        echo'{"categories": [
                "category1",
                "category2",
                "category3"
                ]
            }';
42 43 44 45 46 47 48 49 50 51 52 53
    }

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

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

};