时间:2021-07-01 10:21:17 帮助过:6人阅读
$key='123456789';//双方约定并保密
$time = time();
$token = md5($key.$time);
$data = file_get_contents("http://www.baidu.com/api/api.php?time=".$time."&token=".$token);
$result = json_decode($data, true);
if($result['success']){
echo 'success';
}else{
echo 'fail';
}
$time = isset($_GET['time'])? $_GET['time'] : '';
$token= isset($_GET['token'])? $_GET['token'] : '';
$key = '123456789';//与上面保持一样
$ret = array();
if(md5($key.$time)==$token){
$ret['success'] = true;
}else{
$ret['success'] = false;
}
header('content-type:application/json;charset=utf8');
echo json_encode($ret);