Skip to content

Commit aa666cd

Browse files
author
Phil Sturgeon
committed
Updated readme.
1 parent 62ab7a1 commit aa666cd

File tree

2 files changed

+91
-24
lines changed

2 files changed

+91
-24
lines changed

README.markdown

Lines changed: 0 additions & 24 deletions
This file was deleted.

README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# CodeIgniter-cURL
2+
3+
CodeIgniter-cURL is a CodeIgniter library which makes it easy to do simple cURL requests
4+
and makes more complicated cURL requests easier too.
5+
6+
## Requirements
7+
8+
1. PHP 5.1+
9+
2. CodeIgniter 1.7.x - 2.0-dev
10+
3. PHP 5 (configured with cURL enabled)
11+
4. libcurl
12+
13+
## Features
14+
15+
* POST/GET/PUT/DELETE requests over HTTP
16+
* HTTP Authentication
17+
* Follows redirects
18+
* Returns error string
19+
* Provides debug information
20+
* Proxy support
21+
* Cookies
22+
23+
## Download
24+
25+
http://philsturgeon.co.uk/code/codeigniter-curl
26+
27+
## Examples
28+
29+
$this->load->library('curl');
30+
31+
### Simple calls
32+
33+
These do it all in one line of code to make life easy. They return the body of the page, or FALSE on fail.
34+
35+
// Simple call to remote URL
36+
echo $this->curl->simple_get('http://example.com/');
37+
38+
// Simple call to CI URI
39+
$this->curl->simple_post('controller/method', array('foo'=>'bar'));
40+
41+
// Set advanced options in simple calls
42+
// Can use any of these flags http://uk3.php.net/manual/en/function.curl-setopt.php
43+
44+
$this->curl->simple_get('http://example.com', array(CURLOPT_PORT => 8080));
45+
$this->curl->simple_post('http://example.com', array('foo'=>'bar'), array(CURLOPT_BUFFERSIZE => 10));
46+
47+
### Advanced calls
48+
49+
These methods allow you to build a more complex request.
50+
51+
// Start session (also wipes existing/previous sessions)
52+
$this->curl->create('http://example.com/');
53+
54+
// Option & Options
55+
$this->curl->option(CURLOPT_BUFFERSIZE, 10);
56+
$this->curl->options(array(CURLOPT_BUFFERSIZE => 10));
57+
58+
// More human looking options
59+
$this->curl->option('buffersize', 10);
60+
61+
// Login to HTTP user authentication
62+
$this->curl->http_login('username', 'password');
63+
64+
// Post - If you do not use post, it will just run a GET request
65+
$post = array('foo'=>'bar');
66+
$this->curl->post($post);
67+
68+
// Cookies - If you do not use post, it will just run a GET request
69+
$vars = array('foo'=>'bar');
70+
$this->curl->set_cookies($vars);
71+
72+
// Proxy - Request the page through a proxy server
73+
// Port is optional, defaults to 80
74+
$this->curl->proxy('http://example.com', 1080);
75+
$this->curl->proxy('http://example.com');
76+
77+
// Proxy login
78+
$this->curl->proxy_login('username', 'password');
79+
80+
// Execute - returns responce
81+
echo $this->curl->execute();
82+
83+
// Debug data ------------------------------------------------
84+
85+
// Errors
86+
$this->curl->error_code; // int
87+
$this->curl->error_string;
88+
89+
// Information
90+
$this->curl->info; // array
91+

0 commit comments

Comments
 (0)