php get_post 提交
来源:互联网 发布:app软件产品说明书 编辑:程序博客网 时间:2024/06/09 03:47
<?php$url = 'http://localhost/1/3.php';//geT数据$get = array("corpid"=>"wxae30ce9dc34e65bb","corpsecret"=>"r10Y79hyGZGuyv5p_pzNVIJb9dWFQSBs_NTw7RUA88waV94DhZ5KeIGRERacO4mN");//posT数据$post = array();echo Http($url, $get, $post);/* *@param String $url是请求地址 *@param Array $getData 是GET数据 *@param Array $postData */ function Http($url, $getData, $postData) { if (!is_string($url) || (!is_array($getData)) || (!is_array($postData))) { return ''; }$getData2=$getData; //读取url后面参数 $parse_url = parse_url($url);$query_keys=array_keys($parse_url);if(in_array("query",$query_keys)){$urldata = $parse_url['query']; parse_str($urldata, $get); //整合两部分get数据$getData = array_merge($getData, $get);$param = "?".http_build_query($getData);//注意这里http_build_query已经将参数urlencode处理}else{} $param2=http_build_query($getData2);$url_with_get = $url.$param2; if (function_exists('curl_init')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url_with_get); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); curl_close($ch); return $result; } else { $content = http_build_query($postData); $content_length = strlen($content); $context = array( 'http' => array( 'method' => 'POST', 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'header' => 'Content-Type: ' . 'text/html' . "\r\n" . 'Content-Length: ' . $content_length, 'content' => $content ) ); $context_id = stream_context_create($context); $sock = fopen($url_with_get, 'r', false, $context_id); $result = ''; if ($sock) { while (!feof($sock)){ $result .= fgets($sock, 4096); } fclose($sock); } return $result; } }?>
0 0
- php get_post 提交
- get_post
- GET_POST
- ASIRequest的GET_POST请求数据
- java后台get_post页面请求
- ASIRequest的GET_POST请求数据
- HTTP的get_post请求方法
- PHP模拟表单提交
- PHP数据提交思想
- PHP curl_init Post 提交
- php post 提交
- PHP 表单提交
- php表单提交 代码
- php 表单提交
- php 提交表单
- PHP提交后跳转
- PHP CURL POST提交
- PHP提交表单
- linux 编译选项中加入-shared 造成执行程序coredump
- matlab图片,矩阵,函数的基本用法
- 循环链表
- ubuntu 使用
- 快速排序算法
- php get_post 提交
- [转载论文]蚁群算法在最优路径上的应用
- The final local variable xxx cannot be assigned, since it is defined in an enclosing type“,
- Android之View篇①
- Android之使用wifi连接adb
- 3D拾取技术
- 关于简历的那些事——记微信内推之无知
- 聚类
- HDU 3340 Rain in ACStar(线段树+几何)