From a61e350705d454be6dde905a0aaac7fa804cd524 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Fri, 29 Jun 2018 09:08:16 +0200 Subject: [PATCH] =?UTF-8?q?Script=20zum=20Holen=20der=20Matrikelnummer=20C?= =?UTF-8?q?learingdaten=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- system/matrikelnummer_clearing_download.php | 109 ++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 system/matrikelnummer_clearing_download.php diff --git a/system/matrikelnummer_clearing_download.php b/system/matrikelnummer_clearing_download.php new file mode 100644 index 000000000..4f2534d97 --- /dev/null +++ b/system/matrikelnummer_clearing_download.php @@ -0,0 +1,109 @@ + + */ +/** + * Holt die Ergebnisse des Matrikelnummer Clearings des Datenverbundes + */ +require_once('../config/vilesci.config.inc.php'); +require_once('../include/functions.inc.php'); +require_once('../include/benutzerberechtigung.class.php'); + +$uid = get_uid(); +$rechte = new benutzerberechtigung(); +$rechte->getBerechtigungen($uid); +if(!$rechte->isBerechtigt('admin', null, 'suid')) + die($rechte->errormsg); + +$be = DVB_BILDUNGSEINRICHTUNG_CODE; +$username = DVB_USERNAME; +$passwort = DVB_PASSWORD; +$meldedatum = '20180415'; + + +// OAuth Token holen +$curl = curl_init(); +$url = 'https://stubei-q.portal.at/dvb/oauth/token?grant_type=client_credentials'; + +curl_setopt($curl, CURLOPT_URL, $url); +curl_setopt($curl, CURLOPT_POST, true); +curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); +curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); +curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + +$headers = array( + 'Accept: application/json', + 'Content-Type: application/x-www-form-urlencoded', + 'Authorization: Basic '.base64_encode($username.":".$passwort), + 'User-Agent: FHComplete', + 'Connection: Keep-Alive', + 'Expect:', + 'Content-Length: 0' +); +curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); + +$json_response = curl_exec($curl); +$curl_info = curl_getinfo($curl); +curl_close($curl); + +if ($curl_info['http_code'] == '200') +{ + $authentication = json_decode($json_response); + $token = $authentication->access_token; +} +else +{ + echo 'Request Failed with HTTP Code:'.$curl_info['http_code'].' and Response:'.$json_response; + exit; +} + +// Clearing Daten holen +$curl = curl_init(); + +$url = 'https://stubei-q.portal.at/rws/clearing/0.2/clearing-upload.xml'; +$url .= '?be='.$be.'&meldedatum='.$meldedatum; + +curl_setopt($curl, CURLOPT_URL, $url); +curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); +curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); +curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + +$headers = array( + 'Accept: application/json', + 'Authorization: Bearer '.$token, + 'User-Agent: FHComplete', + 'Connection: Keep-Alive', + 'Expect:', + 'Content-Length: 0' +); +curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); + +$response = curl_exec($curl); +$curl_info = curl_getinfo($curl); +curl_close($curl); + +if ($curl_info['http_code'] == '200') +{ + header("Content-type: application/xhtml+xml"); + echo $response; +} +else +{ + echo 'Request Failed with HTTP Code:'.$curl_info['http_code'].' and Response:'.$response; + return false; +}