PHP Classes

MASNathan Curl: Send HTTP requests with the Curl extension

Recommend this page to a friend!
  Info   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 393 This week: 1All time: 6,625 This week: 571Up
Version License PHP version Categories
masnathan-curl 0.0.5MIT/X Consortium ...5.4HTTP, PHP 5
Description 

Author

This package can send HTTP requests with the Curl extension.

It can send HTTP GET, POST, PUT and DELETE requests taking the request URL as a string and other options in an array parameter.

Alternatively it can setup a request with calls to define the values of individual options before executing the request.

Picture of Andre Roque Filipe
  Performance   Level  
Name: Andre Roque Filipe is available for providing paid consulting. Contact Andre Roque Filipe .
Classes: 9 packages by
Country: Portugal Portugal
Age: 31
All time rank: 123215 in Portugal Portugal
Week rank: 420 Up4 in Portugal Portugal Up
Innovation award
Innovation award
Nominee: 2x

Recommendations

Very Fast Curl class
The fastest Curl class

Details

Curl

Downloads with Composer SensioLabs Insight ReiDuKuduro @gittip

Another Curl Library...

How to install via Composer

The recommended way to install is through Composer.

# Install Composer
$ curl -sS https://getcomposer.org/installer | php

# Add curl as a dependency
$ php composer.phar require masnathan/curl:dev-master

Once it's installed, you need to require Composer's autoloader:

require 'vendor/autoload.php';

How to use

The basic way

$curl = new Curl();

//These are the fast-forward methods
$curl->get(string $url [, array $params]);
$curl->post(string $url [, array $params]);
$curl->put(string $url [, array $params]);
$curl->delete(string $url [, array $params]);

//or you can do it like a true ninja
$response = $curl
            ->init()
            ->setOpt(CURLOPT_URL, 'http://somedomain.com/')
            ->setOpt(CURLOPT_SSL_VERIFYHOST, 0)
            ->setOpt(CURLOPT_SSL_VERIFYPEER, false)
            ->setOpt(CURLOPT_CONNECTTIMEOUT, 5)
            ->setOpt(CURLOPT_RETURNTRANSFER, true)
            ->execute();
$curl->close();

//or you can login onto a website
$curl->init();
$login_page   = $curl->login('http://somedomain.com/login', array('username' => 'my_user', 'password' => 'my_fancy_password'), '/path/to/my/cookie.txt');
$private_page = $curl->get('http://somedomain.com/private_page');

The "not so basic until you know it" way

//These are the fast-forward methods
Ch::get( string $url [, array $params [, function $callback [, string $data_type]]]);
Ch::post( string $url [, array $params [, function $callback [, string $data_type]]]);
Ch::postJson( string $url [, array $params [, function $callback [, string $data_type]]]);
Ch::postXml( string $url [, array $params [, function $callback [, string $data_type]]]);
Ch::put( string $url [, array $params [, function $callback [, string $data_type]]]);
Ch::delete( string $url [, array $params [, function $callback [, string $data_type]]]);

//Here are a few examples:
Ch::get('http://somedomain.com');
Ch::get('http://somedomain.com', array('param1' => 'some value', 'param2' => 'some other value'));
Ch::get('http://somedomain.com', array('param1' => 'some value', 'param2' => 'some other value'), function(data) { var_dump($data); });
Ch::get('http://somedomain.com', array('param1' => 'some value', 'param2' => 'some other value'), function(data) { var_dump($data); }, 'json');
Ch::get('http://somedomain.com', array('param1' => 'some value', 'param2' => 'some other value'), 'json');
Ch::get('http://somedomain.com', 'xml');
Ch::get('http://somedomain.com', function(data) { var_dump($data); }, 'json');
//Any of the above examples is aceptable

License

This library is under the MIT License, see the complete license here

Is your project using MASNathan\Curl? Let me know!


  Files folder image Files  
File Role Description
Files folder imagesrc (1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
Files folder imageMASNathan (1 directory)

  Files folder image Files  /  src  /  MASNathan  
File Role Description
Files folder imageCurl (3 files, 1 directory)

  Files folder image Files  /  src  /  MASNathan  /  Curl  
File Role Description
Files folder imageException (1 file)
  Plain text file Ch.php Class Class source
  Plain text file Curl.php Class Class source
  Plain text file StringParser.php Class Class source

  Files folder image Files  /  src  /  MASNathan  /  Curl  /  Exception  
File Role Description
  Plain text file InvalidArgsException.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:393
This week:1
All time:6,625
This week:571Up