Work with cURL easily from your CodeIgniter application.

Contributor philsturgeon
Email : Log in to view
Author Website http://philsturgeon.co.uk/
Repository Type : git
Number of Installs : 10,474

Get the Latest

  • 1.3.0Pushed October 1st, 2013
     

    php tools\spark install -v1.3.0 curlOr download this version manually: Get curl-1.3.0.zip

How-To

CodeIgniter-cURL

CodeIgniter-cURL is a CodeIgniter library which makes it easy to do simple cURL requests and makes more complicated cURL requests easier too.

Requirements

  1. PHP 5.1+
  2. CodeIgniter 1.7.x - 2.0-dev
  3. PHP 5 (configured with cURL enabled)
  4. libcurl

Features

  • POST/GET/PUT/DELETE requests over HTTP
  • HTTP Authentication
  • Follows redirects
  • Returns error string
  • Provides debug information
  • Proxy support
  • Cookies

Download

http://philsturgeon.co.uk/code/codeigniter-curl

Examples

$this->load->library('curl');

Simple calls

These do it all in one line of code to make life easy. They return the body of the page, or FALSE on fail.

// Simple call to remote URL
echo $this->curl->simple_get('http://example.com/'); // Simple call to CI URI
$this->curl->simple_post('controller/method', array('foo'=>'bar')); // Set advanced options in simple calls
// Can use any of these flags http://uk3.php.net/manual/en/function.curl-setopt.php $this->curl->simple_get('http://example.com', array(CURLOPT_PORT => 8080));
$this->curl->simple_post('http://example.com', array('foo'=>'bar'), array(CURLOPT_BUFFERSIZE => 10));

Advanced calls

These methods allow you to build a more complex request.

// Start session (also wipes existing/previous sessions)
$this->curl->create('http://example.com/'); // Option & Options
$this->curl->option(CURLOPT_BUFFERSIZE, 10);
$this->curl->options(array(CURLOPT_BUFFERSIZE => 10)); // More human looking options
$this->curl->option('buffersize', 10); // Login to HTTP user authentication
$this->curl->http_login('username', 'password'); // Post - If you do not use post, it will just run a GET request
$post = array('foo'=>'bar');
$this->curl->post($post); // Cookies - If you do not use post, it will just run a GET request
$vars = array('foo'=>'bar');
$this->curl->set_cookies($vars); // Proxy - Request the page through a proxy server
// Port is optional, defaults to 80
$this->curl->proxy('http://example.com', 1080);
$this->curl->proxy('http://example.com'); // Proxy login
$this->curl->proxy_login('username', 'password'); // Execute - returns responce
echo $this->curl->execute(); // Debug data ------------------------------------------------ // Errors
$this->curl->error_code; // int
$this->curl->error_string; // Information
$this->curl->info; // array
原文地址:http://getsparks.org/packages/curl/show
CI的REST实现:http://tech.chinaunix.net/a2011/0420/1180/000001180783.shtml

**CodeIgniter-cURL扩展的更多相关文章

  1. Curl扩展开启失败解决方案

    1.php.ini 开启curl扩展 2.设置有时候开启之后,curl还是不能将php目录下的libssh2.dll复制到apache/bin下.(基本上可以成功) 3. 如果没有开启成功,将php安 ...

  2. linux下安装编译php的curl扩展

    curl扩展的位置(需要编译的版本)/root/install/php-5.5.24/ext/curl 1.进入对应的扩展目录 # cd /root/install/php-5.5.24/ext/cu ...

  3. linux下php增加curl扩展,生成curl.so文件

    进入php源代码目录 cd /php5.6.9/ext/curl 执行生成so文件编译模式 /usr/local/php/bin/phpize 编译curl扩展 ./configure --with- ...

  4. Linux中PHP如何安装curl扩展方法

    如果php已经在系统编译好,后来又需要添加新的扩展. 一种方式就是重新完全编译php,另一种方式就是单独编译扩展库,以extension的形式扩展. 下面以安装curl扩展为例: 1.下载curl安装 ...

  5. 开启CURL扩展,让服务器支持PHP curl函数(远程采集)

    关于开启Curl的方法模板天下小编在此给大家简单说一下 curl().file_get_contents().snoopy.class.php这三个远程页面抓取或采集中用到的工具,默迹还是侵向于用sn ...

  6. 在PHP中开启CURL扩展,使其支持curl()函数

    在用PHP开发CMS的时候,要用到PHP的curl函数,默认状态下,这个函数需要开启CURL扩展,有主机使用权的,可通过PHP.ini文件开启本扩展,方法如下: 1.打开php.ini,定位到;ext ...

  7. 设置php在apache下加载ini配置文件路径,~和curl扩展无法加载的问题

    php以模块的方式加载到apache的时候,php配置文件目录为C:windows.这不合理,应该选择php本身目录的配置文件加载,可以在apache的httpd.conf配置文件里设置PHPIniD ...

  8. wecenter—开启CURL扩展,让服务器支持PHP curl函数(远程采集)

    curl().file_get_contents().snoopy.class.php这三个远程页面抓取或采集中用到的工具, 默迹还是侵向于用snoopy.class.php,因为他效率比较高且不需要 ...

  9. Ubuntu下安装Wine&WineQQ+Phpstorm+wps+svn+vim(计划任的使用)+flashplayer+curl扩展

    一.安装Wine 1.添加PPA sudo add-apt-repository ppa:ubuntu-wine/ppa 2.更新列表 sudo apt-get update 3.安装Wine sud ...

  10. 添加FB登陆时,需要curl扩展

    安装curl扩展遇到一个傻逼问题 [root@xxx openssl]# /usr/local/php/bin/phpizeCannot find config.m4.Make sure that y ...

随机推荐

  1. 详细MATLAB 中BP神经网络算法的实现

    MATLAB 中BP神经网络算法的实现 BP神经网络算法提供了一种普遍并且实用的方法从样例中学习值为实数.离散值或者向量的函数,这里就简单介绍一下如何用MATLAB编程实现该算法. 具体步骤   这里 ...

  2. Android am命令使用

    一.开启Activity.服务.广播 1.开启Activity.服务.广播基础知识 通过adb shell,可以使用activity manager(arm)工具来执行不同的系统操作,如开启一个act ...

  3. 执行ldconfig命令后报错的解决过程:ldconfig: 目录 /lib 中的 libpng.so 和 libpng15.so.15.13.0 的 so 名称相同但类型不同。

    执行ldconfig命令后报错: 目录 /lib 中的 libpng.so 和 libpng15.so.15.13.0 的 so 名称相同但类型不同. 解决过程: mv /lib/libpng.so ...

  4. django中模板变量与内置标签以及过滤器

    本文参考 官方文档 . 一  模板变量 格式: {{ variable_name }} variable_name   命名规则与变量命名规则类似,允许字符数字下划线,不允许标点. variable_ ...

  5. ElasticStack系列之十 & 生产中的问题与解决方案

    1. 由 gc 引起节点异常 问题: 因为 gc 时会使 jvm 停止工作,如果某个节点 gc 时间过长,master ping 3次(zen discovery默认 ping 失败重试 3 次)不通 ...

  6. python---基础知识回顾(六)网络编程

    python---基础知识回顾(十)进程和线程(进程) python---基础知识回顾(十)进程和线程(多线程) python---基础知识回顾(十)进程和线程(自定义线程池) 一:Socket (一 ...

  7. bzoj千题计划163:bzoj1060: [ZJOI2007]时态同步

    http://www.lydsy.com/JudgeOnline/problem.php?id=1060 以激发器所在节点为根 终止节点一定是叶节点 记录点的子树内最深的终止节点 然后从根往下使用道具 ...

  8. 并查集:POJ No1703 Find them, Catch them

    题目链接:http://poj.org/problem?id=1703 题意:两个坏蛋属于不同的组织,给出两个坏蛋判定是否一个组织. 题解:已知每次输入的两个帮派人员 x, y; 合并 (x, y + ...

  9. php按照指定顺序的排序

    今天遇到一个需求,需要对一个数组按指定顺序进行排序,最终查到个解决办法: $sort_rule = [5,7,3,1,8,2]; $arr = [1,2,3,5,7,8]; //需求,将数组$arr以 ...

  10. python核心编程笔记——Chapter6

    Chapter 6.序列:字符串,列表和元组 这章内容比较多啊,看得比较久,而且题目又难很多. 6.1鉴定一个字符串是否是另外一个字符串的字串,这道题目不是很确定,好像没有直接的判定吧. 直接是否内建 ...