PHP curl get post通用类
<?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; } }
PHP curl get post通用类的更多相关文章
- poi导出excel通用类
一.关键的通用类public class PoiExportUtils { private static HSSFWorkbook workBook; public PoiExportUtils ...
- NPOI MVC 模型导出Excel通用类
通用类: public enum DataTypeEnum { Int = , Float = , Double = , String = , DateTime = , Date = } public ...
- MVC NPOI Linq导出Excel通用类
之前写了一个模型导出Excel通用类,但是在实际应用中,可能不是直接导出模型,而是通过Linq查询后获取到最终结果再导出 通用类: public enum DataTypeEnum { Int = , ...
- NPOI导入导出EXCEL通用类,供参考,可直接使用在WinForm项目中
以下是NPOI导入导出EXCEL通用类,是在别人的代码上进行优化的,兼容xls与xlsx文件格式,供参考,可直接使用在WinForm项目中,由于XSSFWorkbook类型的Write方法限制,Wri ...
- mongdo通用类(C#版)
日前从公司离职,很快,还没休息就步入了现在的公司,开始跟着公司的脚步走. 公司的项目基本都是大数据的,所以在数据库上大部分都是使用Mongodb和Redis,基本都是Nosql型的数据库为主.以前自己 ...
- 我写的一个ExcelHelper通用类,可用于读取或生成数据
读取或生成EXCEL数据的方法有很多,一般常见的有: 1.通过OFFICE EXCEL组件,优点:读取与生成EXCEL文件方便,缺点:服务器上必须安装OFFICE软件,且进程无法及时释放 2.通过第三 ...
- DataTable转List<Model>通用类
/// <summary> /// DataTable转List<Model>通用类[实体转换辅助类] /// </summary> public class Mo ...
- Memcached通用类(基于enyim.com Memcached Client)
一.如果用官方提供的方法,在web.config里面配置好了各个参数和服务器IP.如下图: <?xml version="1.0"?> <configuratio ...
- PHP CURL 多线程 GET/POST 类
PHP CURL 多线程 GET/POST 类 2015-01-01 分类:技术文章 阅读(623) 评论(0) 如果有需要更正或更高效的建议,欢迎在OSchina分享~\(≧▽≦)/~ http:/ ...
随机推荐
- 【转】【Centos】安装 lnmpa 集成开发环境
解压完毕之后执行 ./install.sh lnmpa 系统需求: CentOS/RHEL/Fedora/Debian/Ubuntu/Raspbian Linux系统 需要3GB以上硬盘剩余空间 12 ...
- python 读写配置文件
使用python读写配置文件,写个demo测试一下. #!/usr/bin/env python import os import ConfigParser # 如果文件不存在,就穿件文件. if o ...
- Unity----Scene加载问题
Unity官方提供了4种加载场景(scene)的方法,分别是: 1. Application.LoadLevel():同步加载 2. Application.LoadLevelAsync():异步加载 ...
- Android多国语言的value文件夹命名方式
在res目錄下建立不同名稱的values文件來調用不同的語言包Values文件匯總如下:中文(中國):values-zh-rCN中文(台灣):values-zh-rTW中文(香港):values-zh ...
- mothur summary.seqs 统计fasta文件中每条序列的长度
在介绍summary.seqs的用法之前,我们首先需要搞清楚两个概念: 1)ambiguous bases 中文叫做模糊碱基,对于DNA序列来说,只有ATCG 4种碱基,在IUPAC定义的碱基标准中, ...
- MySQL的varchar长度问题
From: http://blog.csdn.net/longyulu/article/details/7863737 http://dinglin.iteye.com/blog/914276 htt ...
- OpenGL中各种坐标系的理解
转载:https://blog.csdn.net/meegomeego/article/details/8686816 OPENGL坐标系可分为:世界坐标系和当前绘图坐标系. 世界坐标系以屏幕中心为原 ...
- Java多线程——可阻塞的队列BlockingQueue
阻塞队列与Semaphore有些相似,但也不同,阻塞队列是一方存放数据,另一方释放数据,Semaphore通常则是由同一方设置和释放信号量. ArrayBlockingQueue 只有put方法和ta ...
- Android上基于libgdx的游戏开发资料
本来之前想边学边写一个有关libgdx的游戏开发历程的,但是由于自己的懒惰和客观上的各种事情,一直没有搞下去.最近发现了一个大牛写的一本书<Beginning Android Games, 2n ...
- iOS模拟(糟糕的)网络环境
有时候为了模拟在糟糕的网络环境下app的表现,会故意拔网线(断wifi),苹果其实提供了专门的工具来精确地模拟你在几个预设的场景下的网络连接情况:Network Link Conditioner 点击 ...