**CodeIgniter-cURL扩展
Work with cURL easily from your CodeIgniter application.
| Contributor | : philsturgeon |
| : 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
- PHP 5.1+
- CodeIgniter 1.7.x - 2.0-dev
- PHP 5 (configured with cURL enabled)
- 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)原文地址:http://getsparks.org/packages/curl/show
$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
CI的REST实现:http://tech.chinaunix.net/a2011/0420/1180/000001180783.shtml
**CodeIgniter-cURL扩展的更多相关文章
- Curl扩展开启失败解决方案
1.php.ini 开启curl扩展 2.设置有时候开启之后,curl还是不能将php目录下的libssh2.dll复制到apache/bin下.(基本上可以成功) 3. 如果没有开启成功,将php安 ...
- linux下安装编译php的curl扩展
curl扩展的位置(需要编译的版本)/root/install/php-5.5.24/ext/curl 1.进入对应的扩展目录 # cd /root/install/php-5.5.24/ext/cu ...
- linux下php增加curl扩展,生成curl.so文件
进入php源代码目录 cd /php5.6.9/ext/curl 执行生成so文件编译模式 /usr/local/php/bin/phpize 编译curl扩展 ./configure --with- ...
- Linux中PHP如何安装curl扩展方法
如果php已经在系统编译好,后来又需要添加新的扩展. 一种方式就是重新完全编译php,另一种方式就是单独编译扩展库,以extension的形式扩展. 下面以安装curl扩展为例: 1.下载curl安装 ...
- 开启CURL扩展,让服务器支持PHP curl函数(远程采集)
关于开启Curl的方法模板天下小编在此给大家简单说一下 curl().file_get_contents().snoopy.class.php这三个远程页面抓取或采集中用到的工具,默迹还是侵向于用sn ...
- 在PHP中开启CURL扩展,使其支持curl()函数
在用PHP开发CMS的时候,要用到PHP的curl函数,默认状态下,这个函数需要开启CURL扩展,有主机使用权的,可通过PHP.ini文件开启本扩展,方法如下: 1.打开php.ini,定位到;ext ...
- 设置php在apache下加载ini配置文件路径,~和curl扩展无法加载的问题
php以模块的方式加载到apache的时候,php配置文件目录为C:windows.这不合理,应该选择php本身目录的配置文件加载,可以在apache的httpd.conf配置文件里设置PHPIniD ...
- wecenter—开启CURL扩展,让服务器支持PHP curl函数(远程采集)
curl().file_get_contents().snoopy.class.php这三个远程页面抓取或采集中用到的工具, 默迹还是侵向于用snoopy.class.php,因为他效率比较高且不需要 ...
- 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 ...
- 添加FB登陆时,需要curl扩展
安装curl扩展遇到一个傻逼问题 [root@xxx openssl]# /usr/local/php/bin/phpizeCannot find config.m4.Make sure that y ...
随机推荐
- 从新浪JS服务器获得股票和股指深度行情(.NET)
当我们需要通过网络来自动获取股指或股票的深度行情时,一般有以下两种方法可以获得.目前除了使用Python进行爬虫获取(需要解析html获得)外还可以通过新浪提供的JS行情服务器获得,本文采用的是后者( ...
- django中的转义
什么是html转义? 所谓html转义就是将 html关键字(包括标签,特殊字符等) 进行过滤替换.过滤替换格式如下: 接下来我们通过实例演示django中转义的细节以及如何关闭转义 一 dja ...
- 转:SkipList跳表
http://kenby.iteye.com/blog/1187303 相关概念: 1.几何分布 http://baike.baidu.com/link?url=DdtNq6pCWIvr7onVBtE ...
- Hi35xx 通用GPIO 使用篇(板子3G电源控制脚说明)
在一个嵌入式系统中使用最多的莫过于 通用输入输出 GPIO口.看到论坛中经常有朋友问海思为什么没有提供GPIO驱动.其实不然. 在海思SDK xxx/osdrv/tools/board_tools/ ...
- css选择器 nth-child
html代码: <div> <p>多云转晴</p> <p>多云转晴</p> <p>多云转晴</p> <p> ...
- Redis总体 概述,安装,方法调用
1 什么是redis redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链表).set(集合)和zset( ...
- tips 前端 bootstrap 嵌套行 嵌套列 溢出 宽度不正确 栅格化系统计算
bootstrap 当嵌套列时 有时会出现很奇异的row 的width不对问题出现的情况时 <div class="row" > <!--row a--> ...
- vue短信验证性能优化写入localstorage中
平时我们在项目中进行注册等的时候,会经常用到短信验证的功能,但是现在现在很多短信验证都是存在下面几个问题,例如短信验证时间为60s的时候, 1. 当点击完按钮时,倒计时还没到60s过完时,刷新浏览器, ...
- 2017 清北济南考前刷题Day 7 morning
期望得分:100+50+20=170 实际得分:10+50+20=80 1. 纸牌 题目描述 在桌面上放着n张纸牌,每张纸牌有两面,每面都写着一个非负整数.你的邪王真眼可以看到所有牌朝上的一面和朝下的 ...
- 基于Ubuntu16.04搭建WordPress
安装 Apache2 在终端输入该命令 ,使用 apt-get 安装 Apache2: sudo apt-get install apache2 -y 安装好后,您可以通过访问实验室IP地址 http ...