php jsonインタフェースdemo
1257 ワード
<?php
class Student
{
public $no;
public $username;
public $password;
}
$student=new Student();
$student->no=11;
$student->username='xxx';
$student->password='hehe';
echo json_encode($student);
$result=array(
'no'=>$student->no,
'password'=>$student->password,
'username'=>$student->username
);
echo json_encode($result);
$arr=array();
array_push($arr,$student);
$student=new Student();
$student->no=12;
$student->username='fdsadf';
$student->password=' ';
array_push($arr,$student);
$student=new Student();
$student->no=13;
$student->username='xx';
$student->password=' ';
array_push($arr,$student);
echo json_encode($arr);
?>
phpはmd 5 sha 1とtokenを取得する
<?php
date_default_timezone_set('PRC');
$str=date("Y-m-d",time());
echo $str;
echo '<br/>';
$result='ws'.$str;
echo $result;
echo '<br/>';
$result=md5($result);
echo $result;
echo '<br/>';
$authaccesstoken=sha1('ws'.$result);
echo $authaccesstoken;
echo '<br/>';
?>