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. P1022 计算器的改良

    P1022 计算器的改良 题目背景 NCL 是一家专门从事计算器改良与升级的实验室,最近该实验室收到了某公司所委托的一个任务:需要在该公司某型号的计算器上加上解一元一次方程的功能.实验室将这个任务交给 ...

  2. Java基础-面向对象第一特性之封装(Encapsulation)

    Java基础-面向对象第一特性之封装(Encapsulation) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.理解什么是面向过程和面向对象 面向过程与面向对象都是我们编程中 ...

  3. PHP运算符的规律

    ^异或的规律:只有真真和假假位假 !非 判断失误的另一名比如true是false &只要有真都为真就是真其他都是假 $$就是左边是真的就不判断了 规律是一样的 |或只有假假都为假其他都是真

  4. bzoj千题计划154:bzoj3343: 教主的魔法

    http://www.lydsy.com/JudgeOnline/problem.php?id=3343 high记录原始身高 HIGH记录每块排序之后的身高 不满一块的直接对high操作,重排之后再 ...

  5. jenkins 相关默认信息

    (1) 默认安装目录    /usr/lib/jenkins/:jenkins安装目录,WAR包会放在这里.  ( 2 )  默认配置文件 /etc/sysconfig/jenkins:jenkins ...

  6. 一个JavaScript组件都需要哪些基础api

    { init: function() { // 模块初始化,包括属性初始化和配置初始化及调用父类的初始化方法 } ,build: function() { // 模块构建,包括子模块构建,dom构建, ...

  7. 20155230 2016-2017-2《Java程序设计》第六周学习总结

    20155230 2016-2017-2 <Java程序设计>第6周学习总结 教材学习内容总结 Java将输入/输出抽象化为串流,数据有来源及目的地,衔接两者的是串流对象. 从应用程序角度 ...

  8. laravel new xxx 安装laravel 慢的问题

    问题:使用官方文档上安装 laravel laravel new xxx 安装速度奇慢无比,设置了composer 全局镜像也没有用 composer config -g repo.packagist ...

  9. 【leetcode 简单】 第七十九题 区域和检索 - 数组不可变

    给定一个整数数组  nums,求出数组从索引 i 到 j  (i ≤ j) 范围内元素的总和,包含 i,  j 两点. 示例: 给定 nums = [-2, 0, 3, -5, 2, -1],求和函数 ...

  10. Linux/Unix系统编程手册 第一章:历史和标准

    Unix的开发不受控于某一个厂商或者组织,是由诸多商业和非商业团体共同贡献进行演化的.这导致两个结果:一是Unix集多种特性于一身,二是由于参与者众多,随着时间推移,Unix实现方式逐渐趋于分裂. 由 ...