作者:hzcwd | 更新时间:2019-01-23 | 浏览量:1175
/*
$url:地址
$param:参数(数组)
*/
function send_post($url, $param) {
$options = array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type:application/x-www-form-urlencoded',
'content' => http_build_query($param),
'timeout' => 5
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
return $result;
}
使用方法:
$url = 'https://www.bigiot.net/oauth/token';
$param['grant_type'] = 'password';
$param['client_id'] = '111';
$param['client_secret'] = '1234';
$param['username'] = '123';
$param['password'] = '123';
$rs = send_post($url,$param);