PHP http_response_code Get or Set the HTTP response code
来源:互联网 发布:数据有效性输入空格 编辑:程序博客网 时间:2024/04/29 18:35
PHP http_response_code Get or Set the HTTP response code
PHP模拟POST请求,获取response内容
1 /* 2 * 模拟POST请求,获取response内容 3 */ 4 protected function curl($url, $type, $header, $data) { 5 $CURL_OPTS = array ( 6 CURLOPT_CONNECTTIMEOUT => 10, 7 CURLOPT_RETURNTRANSFER => true, 8 CURLOPT_SSL_VERIFYPEER => false, 9 CURLOPT_TIMEOUT => 60,10 CURLOPT_USERAGENT => 'simulate submit' 11 );12 $opts = $CURL_OPTS;13 $opts [CURLOPT_URL] = $url;14 $opts [CURLOPT_CUSTOMREQUEST] = $type;15 $header [] = 'Expect:';16 $opts [CURLOPT_HTTPHEADER] = $header;17 if ($type == 'POST' || $type == 'PUT') {18 $opts [CURLOPT_POSTFIELDS] = $data;19 }20 21 $ch = curl_init ();22 curl_setopt_array ( $ch, $opts );23 $result = curl_exec ( $ch );24 if (curl_errno ( $ch )) {25 die ( 'CURL error: ' . curl_error ( $ch ) );26 }27 curl_close ( $ch );28 return $result;29 }
参数:
$header = array (
'Content_type: application/x-www-form-urlencoded'
);
$data="param1=qwer¶m2=asdf¶m3=jkl";
分类: PHP
好文要顶 关注我 收藏该文
0
0
(请您对文章做出评价)
« 上一篇:解决360浏览器自动填充的屎黄色背景的问题
» 下一篇:Lucene.net 全文检索 盘古分词
» 下一篇:Lucene.net 全文检索 盘古分词
0 0
- PHP http_response_code Get or Set the HTTP response code
- HTTP、GET、POST、Response Code
- PHP CURL GET HTTP CODE
- Http response code
- Http Response Code[整理]
- Http Response Code[整理]
- Http Response Code
- Http Response Code[整理]
- Http Response Code
- HTTP response code: 403
- com.lzy.okgo.exception.HttpException: network error! http response code is 404 or 5xx!
- HTTP Response Status Code Definitions
- Http Response Code对照备忘
- Http Response Code对照备忘
- HTTP Response Code 中文详解
- AFNetworking Get full http response
- http: get and response格式
- get or set radio value
- 3123: [Sdoi2013]森林 主席树+启发式合并+LCA
- spring-aop学习笔记
- Android 判断SD卡是否存在及容量查询
- 1095. Cars on Campus (30)
- Go语言内存分配器-FixAlloc
- PHP http_response_code Get or Set the HTTP response code
- android 开发技巧(1)--使用 weight 属性实现视图的居中显示
- Go语言内存分配器-MSpan
- c++笔试题总结1
- Andoid 调用相机程序获取图片
- 封装一个Android数据库框架
- 【C/C++】Linux下使用system()函数一定要谨慎
- 有趣的HTML5:离线存储
- Android 从相册选择图片