Skip to content

dlabey/php-curl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple PHP cURL wrapper class

Installation

https://packagist.org/packages/anlutro/curl

composer require anlutro/curl - pick the latest version number from Packagist or the GitHub tag list.

Usage

<?php
$curl = new anlutro\cURL\cURL;

// the raw body from the response is returned
$html = $curl->get('http://www.google.com');

// easily build an url with a query string
$url = $curl->buildUrl('http://www.google.com', ['s' => 'curl']);
$html = $curl->get($url);

// post() takes an array of POST data
$url = $curl->buildUrl('http://api.myservice.com', ['api_key' => 'my_api_key']);
$data = $curl->post($url, ['post' => 'data']);

// add a header before sending a request
$curl->addHeader('Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==');

// get headers from the response
$allHeaders = $curl->getHeaders();
$header = $curl->getHeaders('Accept-Charset');

Comes with a Laravel service provider and facade. Add anlutro\cURL\Laravel\cURLServiceProvider to the array of providers in app/config/app.php, and (optionally) add 'cURL' => 'anlutro\cURL\Laravel\cURL' to the array of aliases in the same file.

About

Simple PHP cURL wrapper class

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%