Code Monkey home page Code Monkey logo

curl's Introduction

#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](https://github.com/ReiDuKuduro/Curl/issues/new?title=New%20script%20using%20Curl&body=Name and Description of your script.)!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.