phpurlpost
A. php 中的 GET 与 POST 有什么区别
1. get是从服务器上获取数据,post是向服务器传送数据。
2. get是把参数数据队列加到提交表单的ACTION属性所指的URL中,值和表单内各个字段一一对应,在URL中可以看到。post是通过HTTP post机制,将表单内各个字段与其内容放置在HTML HEADER内一起传送到ACTION属性所指的URL地址。用户看不到这个过程。
3. 对于get方式,服务器端用Request.QueryString获取变量的值,对于post方式,服务器端用Request.Form获取提交的数据。
4. get传送的数据量较小,不能大于2KB。post传送的数据量较大,一般被默认为不受限制。但理论上,IIS4中最大量为80KB,IIS5中为100KB。
5. get安全性非常低,post安全性较高。但是执行效率却比Post方法好。
建议:
1、get方式的安全性较Post方式要差些,包含机密信息的话,建议用Post数据提交方式;
2、在做数据查询时,建议用Get方式;而在做数据添加、修改或删除时,建议用Post方式;
B. PHP post怎么得到URL
<script type="text/javascript">
var repeatPost=0;
function player(){
$.post("url.php", {"id": "h t tp :/ /film.sohu.c o m/album/9163602. h t m l","type": "auto","siteuser": "","md5": ""},
function(data){
if(data['msg'] == 200){
var isiPad = navigator.userAgent.match(/iPad|iPhone|Android|Linux|iPod/i) != null;
if(data['ext']=='link'){
document.getElementById('a1').innerHTML = '<iframe width="100%" height="100%" allowTransparency="true" frameborder="0" scrolling="no" src="'+data['url']+'"></iframe>';
}else if(isiPad || data['ext']=='h5'){
document.getElementById('a1').innerHTML = '<video src="'+data['url']+'" controls="controls" autoplay="autoplay" width="100%" height="100%"></video>';
}else{
if(data['ext']=='m3u8' || data['ext']=='m3u8_list'){
var flashvars={f:'m3u8.swf',a:data['url'],c:0,s:4,lv:0,p:1,v:100,b:1}
}else if(data['ext']=='mp4'){
var flashvars={f:data['url'],c:0,p:1,v:100,h:1};
}else if(data['ext']=='xml'){
var flashvars={f:data['url'],s:2,c:0,p:1,v:100,b:1};
}
var params={bgcolor:'#FFF',allowFullScreen:true,allowScriptAccess:'always',wmode:'transparent'};
CKobject.embedSWF('ckplayer.swf','a1','ckplayer_a1','100%','100%',flashvars,params);
}
$('#loading').hide();
$('#a1').show();
}else{
$('#loading').hide();
$('#a1').hide();
$('#error').show();
if(data['msg']){
$('#error').html(data['msg']);
}else{
if(repeatPost<4){
var loadingTip = '亲!请稍等,正在重新加载';
for(var i=0;i<=repeatPost;i++){
loadingTip += '.';
}
$('#error').html(loadingTip);
player();
repeatPost++;
}else{
$('#error').html('亲!视频没有播放出来,请刷新一下!');
}
}
}
},"json");
}
player();
</script>
C. 怎么用PHP发送POST请求
PHP发送POST请求的三种方式
classRequest{
publicstaticfunctionpost($url,$post_data='',$timeout=5){//curl
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,1);
if($post_data!=''){
curl_setopt($ch,CURLOPT_POSTFIELDS,$post_data);
}
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
curl_setopt($ch,CURLOPT_HEADER,false);
$file_contents=curl_exec($ch);
curl_close($ch);
return$file_contents;
}
publicstaticfunctionpost2($url,$data){//file_get_content$postdata=http_build_query(
$data
);$opts=array('http'=>
array(
'method'=>'POST',
'header'=>'Content-type:application/x-www-form-urlencoded',
'content'=>$postdata
)
);$context=stream_context_create($opts);
$result=file_get_contents($url,false,$context);
return$result;
}
publicstaticfunctionpost3($host,$path,$query,$others=''){//fsocket
$post="POST$pathHTTP/1.1 Host:$host ";
$post.="Content-type:application/x-www-form-";
$post.="urlencoded ${others}";
$post.="User-Agent:Mozilla4.0 Content-length:";
$post.=strlen($query)." Connection:close $query";
$h=fsockopen($host,80);
fwrite($h,$post);
for($a=0,$r='';!$a;){
$b=fread($h,8192);
$r.=$b;
$a=(($b=='')?1:0);
}
fclose($h);
return$r;
}
}
http://www.oschina.net/code/snippet_729516_33065
D. 如何用php向服务器发送post请求
用PHP向服务器发送HTTP的POST请求,代码如下:
<?php
/**
*发送post请求
*@paramstring$url请求地址
*@paramarray$post_datapost键值对数据
*@returnstring
*/
functionsend_post($url,$post_data){
$postdata=http_build_query($post_data);
$options=array(
'http'=>array(
'method'=>'POST',
'header'=>'Content-type:application/x-www-form-urlencoded',
'content'=>$postdata,
'timeout'=>15*60//超时时间(单位:s)
)
);
$context=stream_context_create($options);
$result=file_get_contents($url,false,$context);
return$result;
}
使用的时候直接调用上面定义的send_post方法:
$post_data=array(
'username'=>'username',
'password'=>'password'
);
send_post('网址',$post_data);
E. PHP的POST参数问题
你好你可以用form表单提交
1、
<formaction="form.php"method="get">
<p>URL:<inputtype="text"name="url"/></p>
<inputtype="submit"value="Submit"/>
</form>
2、在form.php中接收
<?php
$url=$_POST['url'];
echo$url;
?>
希望对你有帮助!
F. php获取post参数的几种方式
方法1、最常见的方法是:$_POST['fieldname'];
说明:只能接收Content-Type: application/x-www-form-urlencoded提交的数据
解释:也就是表单POST过来的数据
方法2、file_get_contents(“php://input”);
说明:
允许读取 POST 的原始数据。
和 $HTTP_RAW_POST_DATA 比起来,它给内存带来的压力较小,并且不需要任何特殊的 php.ini 设置。
php://input 不能用于 enctype=”multipart/form-data”。
解释:
对于未指定 Content-Type 的POST数据,则可以使用file_get_contents(“php://input”);来获取原始数据。
事实上,用PHP接收POST的任何数据都可以使用本方法。而不用考虑Content-Type,包括二进制文件流也可以。
所以用方法二是最保险的方法。
方法3、$GLOBALS['HTTP_RAW_POST_DATA'];
说明:
总是产生 $HTTP_RAW_POST_DATA 变量包含有原始的 POST 数据。
此变量仅在碰到未识别 MIME 类型的数据时产生。
$HTTP_RAW_POST_DATA 对于 enctype=”multipart/form-data” 表单数据不可用
如果post过来的数据不是PHP能够识别的,可以用 $GLOBALS['HTTP_RAW_POST_DATA']来接收,
比如 text/xml 或者 soap 等等
解释:
$GLOBALS['HTTP_RAW_POST_DATA']存放的是POST过来的原始数据。
$_POST或$_REQUEST存放的是 PHP以key=>value的形式格式化以后的数据。
但$GLOBALS['HTTP_RAW_POST_DATA']中是否保存POST过来的数据取决于centent-Type的设置,即POST数据时 必须显式示指明Content-Type: application/x-www-form-urlencoded,POST的数据才会存放到 $GLOBALS['HTTP_RAW_POST_DATA']中。
G. PHP处理由URL传入的字符串参数(post.php)
post是邮件的意思,跟这个有什么关系?
回答:只是一个文件名。什么都不是,这个页面只是用来获取$_GET['entry']后读取对应的日志
url表现在哪里?
回答:这个不明白是什么意思
content是内容的意思,在这里是什么?把它放在$path前边是什么意思?
回答:这个跟英文单词的意思没什么关系,只是形象一点而已,这里只是一个文件夹的名称
entry进入、入口、登陆,在这里的作用是?
回答:只是传参的参数名称
200712-02-215307这段,
0,6是读取6个字符,是200712-吗?
回答:不对,从字符串的下标0开始,截取长度为6,返回200712
7,9,是从02的0读取到-吗?
回答:原理同上,
建议好好看看手册
H. php获取httpPost(url, params)的数据
var_mp($_POST); 不论他是什么语言,只要遵守http协议就可以通过$_GET或者$_POST获取。
I. PHP中怎样发送post请求并获取网页
$post='POST数据';
//初始化
$curl=curl_init('URL');
$header=array();
$header[]='User-Agent:Mozilla/5.0(WindowsNT6.1)AppleWebKit/537.36(KHTML,likeGecko)Chrome/42.0.2311.90Safari/537.36';
curl_setopt($curl,CURLOPT_HTTPHEADER,$header);
//不输出header头信息
curl_setopt($curl,CURLOPT_HEADER,0);
//保存到字符串而不是输出
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
//post数据
curl_setopt($curl,CURLOPT_POST,1);
//请求数据
curl_setopt($curl,CURLOPT_POSTFIELDS,$post);
//是否抓取跳转后的页面
curl_setopt($curl,CURLOPT_FOLLOWLOCATION,1);
$response=curl_exec($curl);
curl_close($curl);
echo$response;