<?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通用类的更多相关文章

  1. poi导出excel通用类

    一.关键的通用类public class PoiExportUtils {    private static HSSFWorkbook workBook; public PoiExportUtils ...

  2. NPOI MVC 模型导出Excel通用类

    通用类: public enum DataTypeEnum { Int = , Float = , Double = , String = , DateTime = , Date = } public ...

  3. MVC NPOI Linq导出Excel通用类

    之前写了一个模型导出Excel通用类,但是在实际应用中,可能不是直接导出模型,而是通过Linq查询后获取到最终结果再导出 通用类: public enum DataTypeEnum { Int = , ...

  4. NPOI导入导出EXCEL通用类,供参考,可直接使用在WinForm项目中

    以下是NPOI导入导出EXCEL通用类,是在别人的代码上进行优化的,兼容xls与xlsx文件格式,供参考,可直接使用在WinForm项目中,由于XSSFWorkbook类型的Write方法限制,Wri ...

  5. mongdo通用类(C#版)

    日前从公司离职,很快,还没休息就步入了现在的公司,开始跟着公司的脚步走. 公司的项目基本都是大数据的,所以在数据库上大部分都是使用Mongodb和Redis,基本都是Nosql型的数据库为主.以前自己 ...

  6. 我写的一个ExcelHelper通用类,可用于读取或生成数据

    读取或生成EXCEL数据的方法有很多,一般常见的有: 1.通过OFFICE EXCEL组件,优点:读取与生成EXCEL文件方便,缺点:服务器上必须安装OFFICE软件,且进程无法及时释放 2.通过第三 ...

  7. DataTable转List<Model>通用类

    /// <summary> /// DataTable转List<Model>通用类[实体转换辅助类] /// </summary> public class Mo ...

  8. Memcached通用类(基于enyim.com Memcached Client)

    一.如果用官方提供的方法,在web.config里面配置好了各个参数和服务器IP.如下图: <?xml version="1.0"?> <configuratio ...

  9. PHP CURL 多线程 GET/POST 类

    PHP CURL 多线程 GET/POST 类 2015-01-01 分类:技术文章 阅读(623) 评论(0) 如果有需要更正或更高效的建议,欢迎在OSchina分享~\(≧▽≦)/~ http:/ ...

随机推荐

  1. qualcomm lk gpio

    关于高通平台lk中控制gpio的记录 http://blog.csdn.net/loongembedded/article/details/72834761 http://blog.csdn.net/ ...

  2. [转]android ANR产生原因和解决办法

    ANR (Application Not Responding) ANR定义:在Android上,如果你的应用程序有一段时间响应不够灵敏,系统会向用户显示一个对话框,这个对话框称作应用程序无响应(AN ...

  3. Numpy存字符串

    # -*- coding: utf-8 -*- import numpy as np student = np.dtype({'names':['name', 'age', 'weight'], 'f ...

  4. SqlServer 数据库引擎优化顾问优化数据库

    现在一直在做的项目,数据量相对也不小,开始的时候没有觉得,因为是刚开始,数据量还很小,在程序使用过程中速度还挺快,但是随着数据量的不停的增长,发现程序越来越慢,甚至出现了超时的问题,因此要对程序和数据 ...

  5. Web APi之HttpClient注意事项以及建议

    Web APi之HttpClient注意事项以及建议 前言 之前对于用SelfHost来手动实现Web API的宿主模式,似乎不是太深入,所以本篇文章我们一起来讨论关于利用HttpClient来访问W ...

  6. 二维数组按某个键值排序 FOR PHP

    $arr=[ array( 'name'=>'小坏龙', 'age'=>28 ), array( 'name'=>'小坏龙2', 'age'=>14 ), array( 'na ...

  7. 网页CSS常用中英文字体收集

    Windows的中文字体: 黑体:SimHei 宋体:SimSun 新宋体:NSimSun 仿宋:FangSong 楷体:KaiTi 仿宋_GB2312:FangSong_GB2312 楷体_GB23 ...

  8. 禁止选中文本JS

    if (typeof(element.onselectstart) != "undefined") { // IE下禁止元素被选取 element.onselectstart = ...

  9. difference between TotalFreeSpace and AvailableFreeSpace

    Refer:http://stackoverflow.com/questions/7275806/what-is-the-difference-between-totalfreespace-and-a ...

  10. DPSR随手笔记

    降质模型 MAP: