php的curl实现get和post
来源:互联网 发布:讯维矩阵 编辑:程序博客网 时间:2024/04/28 07:51
<script type="text/javascript"><!--google_ad_client = "pub-4490194096475053";/* 内容页,300x250,第一屏 */google_ad_slot = "3685991503";google_ad_width = 300;google_ad_height = 250;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
类似于dreamhost这类主机服务商,是显示fopen的使用的。使用PHP的curl可以实现支持FTP、FTPS、HTTP HTPPS SCP SFTP TFTP TELNET DICT FILE和LDAP。curl 支持SSL证书、HTTP POST、HTTP PUT 、FTP 上传,kerberos、基于HTT格式的上传、代理、cookie、用户+口令证明、文件传送恢复、http代理通道就最常用的来说,是基于http的get和post方法。 代码实现:
1、http的get实现
$ch = curl_init("http://www.webjx.com/") ;
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) ;
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true) ;
$output = curl_exec($ch) ;
$fh = fopen("out.html", 'w') ;
fwrite($fh, $output) ;
fclose($fh) ;
2、http的post实现
//extract data from the post
extract($_POST) ;
//set POST variables
$url = 'http://www.webjx.com/get-post.PHP' ;
$fields = array(
'lname'=>urlencode($last_name) ,
'fname'=>urlencode($first_name) ,
'title'=>url
encode($title) ,
'company'=>urlencode($institution) ,
'age'=>urlencode($age) ,
'email'=>urlencode($email) ,
'phone'=>urlencode($phone)
);
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&' ; }
rtrim($fields_string ,'&') ;
//open connection
$ch = curl_init() ;
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL,$url) ;
curl_setopt($ch, CURLOPT_POST,count($fields)) ;
curl_setopt($ch, CURLOPT_POSTFIELDS,$fields_string) ;
//execute post
$result = curl_exec($ch) ;
//close connection
curl_close($ch) ;
- php的curl实现get和post
- php的curl实现get和post
- php的curl实现get和post
- PHP curl实现get,post和cookie
- PHP的curl实现get,post 和 cookie
- php curl实现get和post的代码
- php通过curl实现的POST和GET请求
- php curl post和get
- php curl get和post
- curl实现GET和POST
- cURL实现Get和Post
- 【PHP】cURL实现get,post 和 cookie(几个实例)
- PHP中使用CURL实现GET和POST请求
- PHP中使用CURL实现GET和POST请求
- PHP中使用CURL实现GET和POST请求(详细)
- PHP中使用CURL实现GET和POST请求
- PHP中使用CURL实现GET和POST请求
- PHP中使用CURL实现GET和POST请求
- 在不刷新的情况下动态添加表格行
- CMMI最佳实践之同行评审提升软件品质
- Postgres sql中怎样创建一个序列号或是自动递增的字段?
- 无驱动执行Ring0代码
- PHP控制网页过期时间的程序
- php的curl实现get和post
- DOM应用---遍历网页中的元素
- 简单介绍SSE指令的功能
- 08年生活记录
- C#多线程学习(一) 多线程的相关概念
- 好心情在延续。。。
- 我们的“状态检修”不需要依据国家电网公司的企业标准做...
- DL DT DD标签的详细描述及示例
- vcl学习备忘网址