private function post_request($url,$data,
$json
=false )
{
//post 请求
if($json)
{
$str = 'application/json';
$data = json_encode($data);
}
else
{
$str = 'application/x-www-form-urlencoded';
$data = http_build_query($data);
}
$options[ 'http' ] = array(
'timeout' => 10,
'method' => 'POST',
'header' => "Content-Type: $str;charset=utf-8",
'content' => $data,
);
$context = stream_context_create($options);
return file_get_contents($url, false, $context);
}