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. struts的问题

    将SSH框架进行整合的时候,将三者的jar包加入到lib下面,然后测试struts,结果页面显示不出来报404错误,可是路径没有问题 找到罪魁祸首是:原因两个:(1)在未用到spring的时候,先不要 ...

  2. 题解【bzoj1251 序列终结者】

    Description 维护三个操作:区间加,区间翻转,区间求最大值.\(n \leq 50000\) Solution fhqtreap大法好! 模板题(我是不会告诉你这篇题解是用来存个代码的 Co ...

  3. HDU 3943 数位dp+二分

    K-th Nya Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 125536/65536 K (Java/Others) ...

  4. Java入门:基础算法之获取用户输入

    本部分演示如何获取用户输入.我们使用Scanner类来得到用户输入.下面的实例代码中演示了如何获取用户输入的字符串.整数和float数据.主要用到了以下方法: 1)public String next ...

  5. qq接入

    「花与剑: https://blog.csdn.net/wbbott/article/details/53107009」—————————

  6. Python 字符串前面加u,r,b的含义

    1.字符串前加 u 例:u"我是含有中文字符组成的字符串." 作用: 后面字符串以 Unicode 格式 进行编码,一般用在中文字符串前面,防止因为源码储存格式问题,导致再次使用时 ...

  7. sql service ---- update和delete 误操作数据 ---- 恢复数据

    原文出处:http://blog.csdn.net/dba_huangzj/article/details/8491327 问题: 经常看到有人误删数据,或者误操作,特别是update和delete的 ...

  8. python---重点(设计模式)

    前戏:设计模式简介 设计模式是面向对象设计的解决方案,是复用性程序设计的经验总结.(与语言无关,任何语言都可以实现设计模式) 设计模式根据使用目的的不同而分为创建型模式(Creational Patt ...

  9. opencv 图像处理函数大全

    .cvLoadImage:将图像文件加载至内存: .cvNamedWindow:在屏幕上创建一个窗口: .cvShowImage:在一个已创建好的窗口中显示图像: .cvWaitKey:使程序暂停,等 ...

  10. highCharts使用记录

    公司的架构师让我做一个mockup,要用到highCharts,,以前想接触的,没时间学习,也没有用过,正好工作可以用上了,可以边学边做了. 环境 <script src="./js/ ...