**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 ...
随机推荐
- python文件加入python环境变量
在python中,把一个python文件加入到python环境变量中,以方便其他python文件调用. 方式一: import sys sys.path.append(r'E:\syz\ly-code ...
- Docker简介与安装配置
目录 Docker简介 什么是Docker 为啥要用容器 Docker Engine Docker架构说明 Docker安装 Docker版本介绍 Ubuntu安装docker-ce CentOS7安 ...
- ElasticStack系列之十五 & query cache 引起性能问题思考
问题描述 一个线上集群,执行的 Query DSL 都是一样的,只是参数不同.统计数据显示 98% ~ 99% 的查询相应速度都很快,只需要 4 ~ 6ms,但是有 1% 左右的查询响应时间在 100 ...
- NAT—网络地址转换
参考链接:http://www.qingsword.com/qing/745.html 视频链接: 一.什么是NAT? NAT --- Network Address Translation 也就是 ...
- 科学计算三维可视化---TVTK管线与数据加载(可视化管线和图像管线了解)
一:TVTK的管线 使用管线技术将TVTK中各个对象穿连起来,几乎所有渲染引擎都会提到管线技术 在TVTK中,每个对象只需要实现相对简单的任务,整个管线则能根据用户的需求,实现复杂的数据可视化处理. ...
- Mongo 后台加索引踩坑
背景,随着mongo数据量变大,查询效率变低,要对索引进行优化,所在公司对mongo依赖比较严重,而DBA并不对mongo的权限做控制,所以每个后端开发都有mongo的读写权限,通常每个人各自管理自己 ...
- python字符中加入变量
有时候,我们需要在字符串中加入相应的变量,以下提供了几种字符串加入变量的方法: 1.+ 连字符 name = 'zhangsan' print('my name is '+name) #结果为 my ...
- bzoj千题计划109:bzoj1019: [SHOI2008]汉诺塔
http://www.lydsy.com/JudgeOnline/problem.php?id=1019 题目中问步骤数,没说最少 可以大胆猜测移动方案唯一 (真的是唯一但不会证) 设f[i][j] ...
- python学习笔记4-内置函数、匿名函数、json处理
print(all([1,2,3,4]))#判断可迭代的对象里面的值是否都为真 print(any([0,1,2,3,4]))#判断可迭代的对象里面的值是否有一个为真 print(bin(10))#十 ...
- 网站监控系统安装部署(zabbix,nagios)
zabbix分布式监控系统安装部署 官方网站链接 https://www.zabbix.com/documentation/2.0/manual/installation 安装环境说明 参考地址 ht ...