小庚资源网 · 免费提供绿色软件、活动线报以及其他网络资源,好货不私藏!
当前位置:网站首页 > 技巧分享 > 其他教程 >正文

PHP发送POST请求

作者:小编日期:2023-06-12浏览:6240分类:其他教程

function send_post($url, $post_data) { 

  $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('http://www.jb51.net', $post_data);


暂无评论,来添加一个吧。

取消回复欢迎发表评论:

Copyright© XGW9.COM版权所有〖小庚资源网〗
〖恒创科技〗为本站提供专业云计算服务  
本站发布的内容来源于互联网,如果有侵权内容,请联系我们删除!E-mail:xgzyw6@outlook.com
关于我们|我要投稿|免责声明|XML地图