Example #1
0
    public function simpleCall($url, $request, $cookie = false){
        $urlBase = \mod_mapletadp\helper\MapletaHelper::getConnectionBase(); //todo z konfigurace
        $ch = curl_init($urlBase . $url);

        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        if ($cookie) {
          
            curl_setopt($ch, CURLOPT_COOKIE, 'JSESSIONID='.$cookie);
            curl_setopt($ch, CURLOPT_COOKIESESSION, true);
        }

        $response = curl_exec($ch);

        curl_close($ch);
        return $response;
    }
Example #2
0
 public function __construct(\moodle_database $db, \stdClass $cfg) {
     $this->db = $db;
     $this->cfg = $cfg;
     $this->connectionBase = \mod_mapletadp\helper\MapletaHelper::getConnectionBase();
     $this->helper = new \mod_mapletadp\helper\MapletaHelper();
 }