**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 curl
Or 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 ...
随机推荐
- Qt ------ QPainter 和控件组件的重绘
使用 QPainter 修改 QPaintDevice 的子类,如果 QPaintDevice 的子类也是 QWidget 的子类,比如自定义QWidget子类.QLabel等,需要把 QPainte ...
- UDP ------ UDP 详解
原文地址:https://zhuanlan.zhihu.com/p/25622691 3. UDP疑难杂症 3.1 UDP的传输方式:面向报文 面向报文的传输方式决定了UDP的数据发送方式是一份一份的 ...
- 关于RESTful的理解
如何更好的理解RESTful? (转自https://sanwen8.cn/p/54czrEO.html) 在测试开发中,我们经常接触到API,在调用API时候特别是第三方API时候,我们常常陷入以下 ...
- Go_17:GoLang中如何使用多参数属性传参
我们常常因为传入的参数不确定而头疼不已,golang 为我们提供了接入多值参数用于解决这个问题.但是一般我们直接写已知代码即所有的值都知道一个一个塞进去就好了,但是绝大部分我们是得到用户的大量输入想通 ...
- P1564 膜拜
P1564 膜拜 题目描述 神牛有很多-当然-每个同学都有自己衷心膜拜的神牛. 某学校有两位神牛,神牛甲和神牛乙.新入学的N 位同学们早已耳闻他们的神话. 所以,已经衷心地膜拜其中一位了.现在,老师要 ...
- P1075 质因数分解
P1075 质因数分解 题目描述 已知正整数 n 是两个不同的质数的乘积,试求出两者中较大的那个质数. 输入输出格式 输入格式: 一个正整数 n . 输出格式: 一个正整数 p ,即较大的那个质数. ...
- python中的模块及路径
python在import module的时候 是按照以下顺序去import一个module的: 1. 首先判断这个module是不是built-in即内建模块, 如果是则引入内建模块,如果不是则在一 ...
- HTTP 错误 500.19 请求的页面的相关配置数据无效 解决办法
"HTTP 错误 500.19 请求的页面的相关配置数据无效" 解决办法 HTTP 错误 500.19 - Internal Server Error无法访问请求的页面,因为该 ...
- Dialog插件artDialog
经本人测试,发现没有layer好用,因为artDialog不能拖拽.不过除了拖拽,其他还蛮简洁的,在自定义上的灵活性也还可以.下面是我自己写的测试demo. <!DOCTYPE html> ...
- 织梦自定义表单通过ajax提交的实现方法
自定义表单通过ajax判断,提交不用跳转页面,提高用户体验.具体方法如下: html表单代码部分,就提交按钮改成botton,,添加onclick事件 表单代码: <form action=&q ...