php、asp 发起post请求
来源:互联网 发布:匿名内部类java构造器 编辑:程序博客网 时间:2024/03/29 08:22
asp
使用MSXML2.XMLHTTP发出post请求
参考
现在不再流行,可今天需要写一个支持post的asp程序,好不容易找了个能用的。asp函数返回值就是赋值给一个和函数名相同的变量。
解决乱码问题,
'UTF-8:<%@Language="vbscript" Codepage="65001"%> <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" > </head>`gb2312:<%@Language="vbscript" Codepage="936"%> <head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" ></head>
<%On error resume next '容错处理Function GetBody(ips) '获取远程IP地址POST信息Set https = Server.CreateObject("MSXML2.XMLHTTP") With https .Open "Post", "http://www.ip138.com/ips8.asp", False.setRequestHeader "Content-Type","application/x-www-form-urlencoded".Send "ip="&ips&"&action=2"GetBody = .ResponseBodyEnd With GetBody = BytesToBstr(GetBody,"GB2312")Set https = Nothing End FunctionFunction BytesToBstr(body,Cset) '转换GB2312/utf-8dim objstreamset objstream = Server.CreateObject("adodb.stream")objstream.Type = 1objstream.Mode =3objstream.Openobjstream.Write bodyobjstream.Position = 0objstream.Type = 2objstream.Charset = CsetBytesToBstr = objstream.ReadText objstream.Closeset objstream = nothingEnd FunctionResponse.Write GetBody("61.186.177.105")%>
php
curl 方式,这个直接使用库,但是有问题.
multipart form-data boundary 是被curl改为上传文件的形式。其中的bounty是分割开不同的上传项,随机产生
使用数组提供 post 数据时,CURL 组件大概是为了兼容 @filename 这种上传文件的写法,默认把 content_type 设为了 multipart/form-data。虽然对于大多数服务器并没有影响,但是还是有少部分服务器不兼容。
PHP中CURL的CURLOPT_POSTFIELDS参数使用细节
multipart form-data boundary 说明
POST multipart/form-data与application/x-www-form-urlencode的区别
http://blog.csdn.net/five3/article/details/7181521
<?phpheader("Content-Type:text/html;charset=utf-8");$ch = curl_init();/* 设置验证方式 */curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept:text/plain;charset=utf-8', 'Content-Type:application/x-www-form-urlencoded','charset=utf-8'));/* 设置返回结果为流 */curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);/* 设置超时时间*/curl_setopt($ch, CURLOPT_TIMEOUT, 10);/* 设置通信方式 */curl_setopt($ch, CURLOPT_POST, 1);curl_setopt ($ch, CURLOPT_URL, 'http://baidu.com/add.json');curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('apikey' => '24d20axxxxxxxxxxxxxxxxx', 'content' => ('您关注的#commodity_name#现在活动半价啦,赶快来看看吧!'))));$file_contents = curl_exec($ch);curl_close($ch);print_r($file_contents);?>
发起socket请求
function sock_post($url,$query){ $data = ""; $info=parse_url($url); $fp=fsockopen($info["host"],80,$errno,$errstr,30); if(!$fp){ return $data; } $head="POST ".$info['path']." HTTP/1.0\r\n"; $head.="Host: ".$info['host']."\r\n"; $head.="Referer: http://".$info['host'].$info['path']."\r\n"; $head.="Content-type: application/x-www-form-urlencoded\r\n"; $head.="Content-Length: ".strlen(trim($query))."\r\n"; $head.="\r\n"; $head.=trim($query); $write=fputs($fp,$head); $header = ""; while ($str = trim(fgets($fp,4096))) { $header.=$str; } while (!feof($fp)) { $data .= fgets($fp,4096); } return $data;}
0 0
- php、asp 发起post请求
- php如何发起POST DELETE GET POST 请求
- HttpClient发起post请求
- HttpClient发起POST请求
- ajax发起post请求
- Python向PHP发起GET与POST请求
- php curl发起post请求(json和xml)
- PHP发起异步请求
- 使用python发起post请求
- HttpClient发起GET / POST请求
- HttpClient发起post、get请求
- php 发起 post http请求 ,并传body内容 到另一个php页面
- PHP 如何发起异步请求
- PHP 如何发起异步请求
- HttpClient发起GET或者POST请求
- android中发起POST请求代码
- Java 中使用HttpURLConnection发起POST 请求
- PostMan 模拟AJAX发起POST请求 SpringMVC
- Eclipse下Java链接MySQL数据库
- ERP实施项目的计划阶段要点分析
- C/C++中相对路径与绝对路径以及斜杠与反斜杠的区别
- 关于Java交换两个对象的问题
- 修改ZigBee协调器内存大小
- php、asp 发起post请求
- toj 3072 Train Order
- OC 学习第六天_Block的使用
- 接口和抽象类的区别
- Linux 中mdelay() 与msleep()的区别
- 了解blocks基本语法
- 小问题的解决,小进步
- SPOJ 705 New Distinct Substrings (后缀数组)
- #1116 : 计算