Api.php 544 Bytes
Newer Older
Mindiell's avatar
Mindiell committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<?php

/*
 * Static class for REST API communication
 */
class Api {
    static function get($url) {
        $curl = curl_init();
        $url = API_BASE . $url;
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $result = curl_exec($curl);
        curl_close($curl);
        return $result;
    }

    static function get_campaign() {
        // Asking for campaign informations
        $json = Api::get("campaign/" . CAMPAIGN_ID);
        return json_decode($json, true);
    }

};