<?php 
session_start();
include 'config.php';
include 'lib/EcardBalance.class.php';
if (isset($_POST['sid']) && isset($_POST['password'])) {
    $sid = $_POST['sid'];
    $password = $_POST['password'];
} else {
    header('Location: ecard.php');
    exit;
}
$api = new EcardBalance($sid, $password);
$jsonData = $api->getData();
$jsonArray = json_decode($jsonData, 'true');
?>

<!DOCTYPE html>
<html lang="zh-cn">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="description" content="<?php 
echo $description;
?>
">
	<title>查饭卡 - <?php 
echo $titleName;
?>
</title>
	<link rel="shortcut icon" href="https://open.sky31.com/favicon.ico">
<?php

header("Content-type: text/html; charset=utf-8");
//Init
if (isset($_GET['role']) && isset($_GET['hash']) && isset($_GET['sid']) && isset($_GET['password']) && $_GET['sid'] != '' && $_GET['password'] != '') {
    $role = $_GET['role'];
    $hash = $_GET['hash'];
    $sid = $_GET['sid'];
    $password = $_GET['password'];
} else {
    exit('{"code":65535,"msg":"缺失参数"}');
}
//Verify Hash
include 'lib/VerifyHash.class.php';
$verify = new VerifyHash($role, $hash);
if (!$verify->checkRole()) {
    exit('{"code":-1,"msg":"接口调用身份验证失败"}');
}
//Get Data
include 'lib/EcardBalance.class.php';
$api = new EcardBalance($sid, $password);
echo $api->getData();