post请求

function curl_post($url,$param) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}

 

$_opts = array('http'=>array( 'method'=>"GET", 'timeout'=>3));
$_content = stream_context_create($_opts);
$res = file_get_contents($url,false,$_content);

 

你可能感兴趣的:(post请求)