//GET请求方法
$url="https://www.baidu.com";
$ret=file_get_contents($url);
$list = json_decode($ret,1); //把json转为数组格式,视个人情况转换
//POST和GET通用请求方法
$url="https://www.baidu.com";
$data = ['username' => '***','password' => '***'];
$data = json_encode($data);
$opts = [
'http' => [
'method' => 'POST',
'header' => 'Content-type:application/json',
'content' => $data,
]
];
$context = stream_context_create($opts);
$ret = file_get_contents($url,false,$context);