脚本宝典收集整理的这篇文章主要介绍了php发送post请求的三种方法,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
方法一:
$postdata = http_build_query($post_data);
$options = array(
'http' => array(
'method' => 'POST','header' => 'Content-tyPE:application/x-www-form-urlencoded','content' => $postdata,'timeout' => 15 * 60 // 超时时间(单位:s)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url,false,$context);
return $result;
}
//使用方法
$post_data = array(
'username' => 'stclair2201','password' => 'handan'
);
send_post('//www.js-code.COM',$post_data);
以上是脚本宝典为你收集整理的php发送post请求的三种方法全部内容,希望文章能够帮你解决php发送post请求的三种方法所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。