php模拟post请求(file_get_contents)

作者:admin 发布时间:2018-05-18 23:29:53 浏览:846次
很多时候,我们在使用php进行编程的时候,都会用到get或者post请求,上次在《 php采集或调用api接口常用函数》的里面,已经提到过了get的使用方法,那么今天就来分享下post 的用法。   [cc lang="php"] 'getinfo', 'svname'=>'红海行动', 'svsite'=>'ok'); $data = http_build_query($data); //$postdata = http_build_query($data); $options = array( 'http' => array( 'method' => 'POST', 'header' => 'Content-type:application/x-www-form-urlencoded', 'content' => $data //'timeout' => 60 * 60 // 超时时间(单位:s) ) ); $url = "http://www.zhe94.com"; //要请求的网址 $context = stream_context_create($options); //echo $context; $result = file_get_contents($url, false, $context); echo $result; ?> [/cc]

如需转载请保留本文出处: https://zhe94.com/134.html

上一篇:Best Trace 路由跟踪工具和专业级查ip网站
下一篇:php如何在一段字符串中取出中间文本、左边文本、右边文本