<?php
/**
* @author:xiaojiang
* curl 通用方法 。。get /post 传送数据
*/
class process{ const GET = 0;
const POST = 1;
public $url;
public $ch = null;
private $type = 1; public function __construct( $url , $type = self::POST){
$this->url = $url;
$this->ch = curl_init();
$this->type = $type;
} //设置发送方式 0 get 1 post
public function setType( $type ){
$this->tyep = $type;
}
//post 方式传递数据
public function send( $param ){
if( self::POST == $this->type)
return $this->posts( $param );
else
return $this->gets( $param );
} public function posts( $post_data ){ curl_setopt( $this->ch, CURLOPT_URL, $this->url );
curl_setopt( $this->ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $this->ch, CURLOPT_HEADER, 0 );
curl_setopt($this->ch, CURLOPT_POST, 1);
curl_setopt($this->ch, CURLOPT_POSTFIELDS, $post_data);
$output = curl_exec( $this->ch );
return $output;
} public function gets( $get_data ){ $url = $this->url.'?'.http_build_query($get_data);
curl_setopt( $this->ch, CURLOPT_URL, $url );
curl_setopt( $this->ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $this->ch, CURLOPT_HEADER, 0 );
$output = curl_exec( $this->ch );
return $output; } }

最新文章

  1. setTimeout使用闭包功能,实现定时打印数值
  2. FJOI省队集训 chessboard
  3. Android应用中使用及实现系统“分享”接口
  4. 解决安装office2013时提示已安装相同版本的office
  5. php文件上传之多文件上传
  6. ODTwithODAC认识与安装图解
  7. maven项目编译漏掉src/main/java下的xml配置文件
  8. EasyUI_Datagrid学习总结
  9. Jquery 操作xml 文档的方法
  10. TextView设置动态改变颜色
  11. 最小生成树之算法记录【prime算法+Kruskal算法】【模板】
  12. AngularJS自定义表单验证器
  13. C#9 结构体 员工信息 学生成绩
  14. VICC国际标准ISO15693下载
  15. Java关键字transient和volatile小结(转)
  16. iOS 给UITextView加一个placeholder
  17. 如何用while循环 输出一个九九乘法表
  18. (Matlab)GPU计算所需的配置
  19. 理解Go Interface
  20. Spring Boot的事务处理

热门文章

  1. FTP服务器的配置与实现
  2. powerDesigner生成Html及Word
  3. Spring AOP的日志记录
  4. 使用 SharpSvn 执行 svn 操作的Demo
  5. SpringBoot整合cxf发布webService
  6. ESPCN超分辨率汇总
  7. Docker安装指南
  8. iOS 开发,工程中混合使用 ARC 和非ARC(转)
  9. SpringBoot------热部署(devtools)(推荐)
  10. Linux+Redis实战教程_day01_常用命令【重点】