sientifica / curl
This is a simple cURL library to dispatch HTTP GET, POST, PUT and DELETE request, easily.
dev-master
2019-11-02 15:39 UTC
Requires
- php: >=5.6.0
This package is auto-updated.
Last update: 2024-10-07 11:24:35 UTC
README
This is a simple cURL library to dispatch HTTP GET, POST, PUT and DELETE request for php language projects.
How to use it
- Import the library:
use Sientifica\Curl
- Instantiate a new Sientifica\Curl object:
$curl = new Sientifica\Curl();
- Make any http (any http verb) request you want:
For a HTTP GET request:
$response = $curl->urlGet('https://url-to-get');
For a HTTP POST request:
- HTTP POST, no Content-Type defined
$postData = [
'element1' => 'Value 1',
'element2' => 'Value 2'
];
$response = $curl->urlPost('https://url-to-get',$postData);
- HTTP POST, under json format:
$postData = [
'element1' => 'Value 1',
'element2' => 'Value 2'
];
$headers = [
'Content-Type: application/json'
];
$response = $curl->urlPost('https://url-to-get',$postData,$headers);
- HTTP POST, under multipart/form-data (as regular html web forms)
$postData = [
'element1' => 'Value 1',
'element2' => 'Value 2'
];
$headers = [
'Content-Type: multipart/form-data'
];
$response = $curl->urlPost('https://url-to-get',$postData,$headers);