<?php
	include('include/AuthCode.class.php');
	$key = "d0d3d5b5466cc1ee89eb808de9f5672d";//个人密匙
	$mid = "5b53a2d341d78427feafeb4520bf41eb";//设备密匙
	$url = "https://wx663ca7ac2632b137.vip.aoyacms.com/plugin/aoya/iot/api.php";//接口地址
	$t = time();//获取时间戳
	//控制开关
	$info = array(
		"act" => "switch"
	);
	$json = json_encode($info);//将操作转成json格式
	$ciphertext = AuthCode::encode($json,$key);//密文
	$check = md5($t.$mid.$ciphertext);//md5验证
	//获取开关状态
	$info2 = array(
		"act" => "getState"	
	);
	$json2 = json_encode($info2);
	$ciphertext2 = AuthCode::encode($json2,$key);//密文
	$check2 = md5($t.$mid.$ciphertext2);//md5验证

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>测试</title>
</head>

<body>
    <form action="<?php echo $url;?>" method="post" >
        <input type="hidden" name="ciphertext" value="<?php echo $ciphertext?>"  />
        <input type="hidden" name="t" value="<?php echo $t?>"  />
        <input type="hidden" name="check" value="<?php echo $check?>"  />
        <input type="hidden" name="mid" value="<?php echo $mid?>"  />
        <input type="submit" value="开/关"  />
    </form>
    <form action="<?php echo $url;?>" method="post"  style="margin-top:20px;">
        <input type="hidden" name="ciphertext" value="<?php echo $ciphertext2?>"  />
        <input type="hidden" name="t" value="<?php echo $t?>"  />
        <input type="hidden" name="check" value="<?php echo $check2?>"  />
        <input type="hidden" name="mid" value="<?php echo $mid?>"  />
        <input type="submit" value="获取开关状态"  />
    </form>
</body>
</html>
