private function create_token($token) {
        global $CFG;

        if (!$this->is_system_configured()) {
            return false;
        }

        require_once($CFG->libdir . '/filelib.php');

        $serverurl = $CFG->airnotifierurl . ':' . $CFG->airnotifierport . '/tokens/' . $token;
        $header = array('Accept: application/json', 'X-AN-APP-NAME: ' . $CFG->airnotifierappname,
            'X-AN-APP-KEY: ' . $CFG->airnotifieraccesskey);
        $curl = new curl;
        $curl->setHeader($header);
        $params = array();
        $resp = $curl->post($serverurl, $params);

        if ($token = json_decode($resp, true)) {
            if (!empty($token['status'])) {
                return $token['status'] == 'ok' || $token['status'] == 'token exists';
            }
        }
        debugging("Unexpected response from the Airnotifier server: $resp");
        return false;
    }
private function create_token($token) {
        global $CFG;

        if (!$this->is_system_configured()) {
            return false;
        }

        require_once($CFG->libdir . '/filelib.php');

        $serverurl = $CFG->airnotifierurl . ':' . $CFG->airnotifierport . '/tokens/' . $token;
        $header = array('Accept: application/json', 'X-AN-APP-NAME: ' . $CFG->airnotifierappname,
            'X-AN-APP-KEY: ' . $CFG->airnotifieraccesskey);
        $curl = new curl;
        $curl->setHeader($header);
        $params = array();
        $resp = $curl->post($serverurl, $params);

        if ($token = json_decode($resp, true)) {
            if (!empty($token['status'])) {
                return $token['status'] == 'ok' || $token['status'] == 'token exists';
            }
        }
        debugging("Unexpected response from the Airnotifier server: $resp");
        return false;
    }
private function create_token ( $ token ) { global $ CFG ; if ( ! $ this -> is_system_configured ( ) ) { return false ; } require_once ( $ CFG -> libdir . '/filelib.php' ) ; $ serverurl = $ CFG -> airnotifierurl . ':' . $ CFG -> airnotifierport . '/tokens/' . $ token ; $ header = array ( 'Accept: application/json' , 'X-AN-APP-NAME: ' . $ CFG -> airnotifierappname , 'X-AN-APP-KEY: ' . $ CFG -> airnotifieraccesskey ) ; $ curl = new curl ; $ curl -> setHeader ( $ header ) ; $ params = array ( ) ; $ resp = $ curl -> post ( $ serverurl , $ params ) ; if ( $ token = json_decode ( $ resp , true ) ) { if ( ! empty ( $ token [ 'status' ] ) ) { return $ token [ 'status' ] == 'ok' || $ token [ 'status' ] == 'token exists' ; } } debugging ( "Unexpected response from the Airnotifier server: $resp" ) ; return false ; }
Create a device token in the Airnotifier instance
@param string $token The token to be created
@return bool True if all was right
Create a device token in the Airnotifier instance