1. Post方法
$ch = curl_init();
$data = array(
"firstName"=>"Flora6",
"lastName"=>"Li",
"title"=>"123",
"department"=>"123"
);
curl_setopt($ch, CURLOPT_URL, 'http://***/user/userRegister');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$output = curl_exec($ch);
curl_close($ch);
var_dump(json_decode($output)->code);
2. Get方法
$ch = curl_init("http://***/user/userLogin?email=***@163.com&password=abc123_") ;
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1) ; // 获取数据返回
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1) ; // 在启用 CURLOPT_RETURNTRANSFER 时候将获取数据返回
$output = curl_exec($ch);
curl_close($ch);
var_dump($output);