<?php

require_once "class/consumerService.php";
require_once "class/authController.php";
require_once "class/errorController.php";
//產生錯誤訊息
$consumerService = new consumerService();
$authController = new AuthController();
$errorController = new errorController();
$consumer = $consumerService->getConsumer();
$return_to = $authController->getReturnTo();
$ary_sreg = array();
$ary_axAttr = array();
// 產生consumer後取得OP的回應
$authController->getResponse($consumer, $return_to);
// 回應的狀態為true表示OP有回應
if ($msg = $authController->checkResponseStatus()) {
    $sreg = $authController->getResponseSREG();
    //取得SREG
    /*
    姓名:王大同
    電郵:test1234@test.mail.kh.edu.tw
    性別:M
    生日:1980-01-01
    個人代碼:92d4fe71eaae036ff7209b87cb36a74200dc64a1fb792beebfcdf622d838dbbf
    學校職務:{"sid":"000000","titles":["教師","資訊組長"]} 
    學校業務:{"sid":"000000","affair":[{"affairTitle":"資訊業務","affairType":"負責人"}]} 
    */
    if ($sreg) {
        $ary_sreg = $sreg;
        echo "姓名:" . $sreg["fullname"] . "<br>";