php中运用http调用的GET和POST方法
来源:互联网 发布:吴敦义 知乎 编辑:程序博客网 时间:2024/06/10 08:25
使用到的函数是curl_init, curl_setopt, curl_exec,curl_close。
默认是GET方法,可以选择是否使用Header:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$url");
curl_setopt($ch, CURLOPT_TIMEOUT, 2);
curl_setopt($ch, CURLOPT_HEADER, 1); //如果设为0,则不使用header
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$result = curl_exec($ch);
curl_close($ch);
POST方法:
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,'$url');
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
$vars =sprintf('from=%d&to=%d&subject=%s&body=%s',$from, $to, urlencode($subject), urlencode($body));
curl_setopt($ch,CURLOPT_POSTFIELDS,$vars);
$ret = curl_exec($ch);
curl_close($ch);
默认是GET方法,可以选择是否使用Header:
POST方法:
0 0
- php中运用http调用的GET和POST方法
- php中运用http调用的GET和POST方法
- http中get和post的方法
- http中get方法和post方法的区别
- HTTP中GET方法和POST方法的区别
- HTTP中GET和POST方法异同
- HTTP 中 GET 和 POST 方法的区别
- 【网络】HTTP中GET和POST方法的区别
- HTTP中GET和POST方法的区别
- (经典)http中get和post方法的区别
- HTTP中GET和POST方法的区别
- php中通过post和get传递数组的方法
- Http的get和post方法比较
- http的get和post发送方法
- HTTP方法:get和post的区别
- .net调用别人的http页面,返回结果,url中有中文的处理,get和post两种方法
- http中get和post的区别
- http中get和post的区别
- java知识总结
- Android Scroller实战(二)窗帘效果实现
- 鸟哥的LINUX私房菜学习笔记-----VI/VIM编辑器的使用
- Splash初入系列做法
- 制作植被覆盖指数-使用Flex渲染图层 并且标注图层
- php中运用http调用的GET和POST方法
- 网站上传的图片加水印
- 理解iOS 8中的Self Sizing Cells和Dynamic Type
- Android 广播、服务、数据库、通知、包原理
- JS面向对象编程之对象
- hdu 5023 && poj 2777(线段染色)2014 ACM/ICPC Asia Regional 广州 Online
- jQuery的选择器性能
- sprintf函数在字符串处理的妙用
- 进程与线程