2017 © Pedro Peláez
 

library wcurl

A convenience wrapper around PHP's cURL library

image

sandeepshetty/wcurl

A convenience wrapper around PHP's cURL library

  • Sunday, April 7, 2013
  • by sandeepshetty
  • Repository
  • 1 Watchers
  • 4 Stars
  • 19,772 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 9 Forks
  • 2 Open issues
  • 1 Versions
  • 7 % Grown

The README.md

wcurl

A convenience wrapper around PHP's cURL library, (*1)

Requirements

Download

Via Composer (Preferred)

Create a composer.json file if you don't already have one in your projects root directory and require wcurl:, (*2)

{
    "require": {
        "sandeepshetty/wcurl": "dev-master"
    }
}

Install Composer:, (*3)

$ curl -s http://getcomposer.org/installer | php

Run the install command:, (*4)

$ php composer.phar install

This will download wcurl into the vendor/sandeepshetty/wcurl directory., (*5)

To learn more about Composer visit http://getcomposer.org/, (*6)

Via an archive

Download the latest version of wcurl:, (*7)

$ curl -L http://github.com/sandeepshetty/wcurl/tarball/master | tar xvz
$ mv sandeepshetty-wcurl-* wcurl

Use

Description

string wcurl( string $method , string $url [, mixed $query [, mixed $payload [, array $request_headers [, array &$response_headers [, array $curl_opts ]]]]] ), (*8)

Examples

1, 'per_page'=>2));


    // Basic POST request
    // Parameters you want to skip can be passed as NULL. For example, here the query parameter is passed as NULL.
    $body = wcurl('POST', 'http://duckduckgo.com/', NULL, array('q'=>'42', 'format'=>'json'));


    // POST request with a custom request header (Content-Type) and an overriden cURL opt (CURLOPT_USERAGENT)
    // Also passing in a variable ($response_headers) to get back the response headers
    $response_headers = array();
    $response_body = wcurl
    (
        'POST',
        'https://api.github.com/gists',
        NULL,
        stripslashes(json_encode(array('description'=>'test gist', 'public'=>true, 'files'=>array('42.txt'=>array('content'=>'The Answer to the Ultimate Question of Life, the Universe, and Everything'))))),
        array('Content-Type: application/json; charset=utf-8'),
        $response_headers,  // This variable is filled with the response headers
        array(CURLOPT_USERAGENT=>'MY_APP_NAME')
    );

?>

The Versions

07/04 2013

dev-master

9999999-dev https://github.com/sandeepshetty/wcurl

A convenience wrapper around PHP's cURL library

  Sources   Download

MIT

The Requires

  • php >=5.0.0

 

api curl http