CURL模拟POST/GET
来源:互联网 发布:地牢探测器JS手机版 编辑:程序博客网 时间:2024/05/29 12:29
<?php/*** Send a POST requst using cURL* @param string $url to request* @param array $post values to send* @param array $options for cURL* @return string*/function curl_post($url, array $post = NULL, array $options = array()){ $defaults = array( CURLOPT_POST => 1, CURLOPT_HEADER => 0, CURLOPT_URL => $url, CURLOPT_FRESH_CONNECT => 1, CURLOPT_RETURNTRANSFER => 1, CURLOPT_FORBID_REUSE => 1, CURLOPT_TIMEOUT => 4, CURLOPT_POSTFIELDS => http_build_query($post) ); $ch = curl_init(); curl_setopt_array($ch, ($options + $defaults)); if( ! $result = curl_exec($ch)) { trigger_error(curl_error($ch)); } curl_close($ch); return $result;}/*** Send a GET requst using cURL* @param string $url to request* @param array $get values to send* @param array $options for cURL* @return string*/function curl_get($url, array $get = NULL, array $options = array()){ $defaults = array( CURLOPT_URL => $url. (strpos($url, '?') === FALSE ? '?' : ''). http_build_query($get), CURLOPT_HEADER => 0, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_TIMEOUT => 4 ); $ch = curl_init(); curl_setopt_array($ch, ($options + $defaults)); if( ! $result = curl_exec($ch)) { trigger_error(curl_error($ch)); } curl_close($ch); return $result;}?>
官网案例 curl_exec( )
function request_by_curl($remote_server,$post_string){ $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$remote_server); curl_setopt($ch,CURLOPT_POSTFIELDS,'data='.$post_string); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); //curl_setopt($ch,CURLOPT_USERAGENT,"Jimmy's CURL Example beta"); $data = curl_exec($ch); curl_close($ch); return $data; }
0 0
- CURL模拟POST/GET
- curl 模拟 get和post
- curl模拟POST,GET提交
- php使用curl可以get 模拟post
- PHP CURL模拟GET及POST函数
- PHP CURL模拟GET及POST函数
- curl 模拟get和post请求
- CURL 模拟get和post请求
- curl模拟get和post请求
- 使用curl 命令模拟POST/GET请求
- curl模拟delete/put/post/get请求
- curl类,可用于模拟get,post和curl下载
- curl类,可用于模拟get,post和curl下载
- CURL模拟进行微信接口的GET与POST
- PHP CURL模拟GET及POST函数代码
- Linux 下curl模拟Http 的get or post请求
- Linux 下curl模拟Http 的get or post请求。
- Linux 下curl模拟Http 的get or post请求。
- HTML 中有用的字符实体
- Linux下解析配置文件
- 6、数据库锁机制
- linux鸟哥私房菜学习笔记之三-shell
- ImageView的属性android:scaleType作用
- CURL模拟POST/GET
- iOS 字体
- Android 百度地图开发(一)--- 申请API Key和在项目中显示百度地图
- ARM的irq和fiq中断以及中断嵌套
- MVC和MVP模式——什么区别?
- CxBrowser, the open source / experimental web browser.
- 谈黑客
- 关于之前对#pragma pack ()误解的纠正
- ios7 uitableview 上面的空白处理