https://github.com/gatorv/simple-http
Simple HTTP Request Library for PHP using cURL
https://github.com/gatorv/simple-http
curl php
Last synced: 17 days ago
JSON representation
Simple HTTP Request Library for PHP using cURL
- Host: GitHub
- URL: https://github.com/gatorv/simple-http
- Owner: gatorv
- Created: 2017-08-10T08:24:48.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-08-18T07:11:13.000Z (over 8 years ago)
- Last Synced: 2024-04-29T13:21:09.992Z (almost 2 years ago)
- Topics: curl, php
- Language: PHP
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
SimpleHttpRequest Class
================
Simple PHP Http Request Wrapper using cURL under the hood.
## Installation
```sh
$ php composer.phar require gatorv/simple-http
```
## Usage
Basic Usage
```php
use Gatorv\Web\SimpleHttpRequest as Request;
$req = new Request();
list($headers, $body) = $req->get('https://url/');
```
### Main Methods
Perform a GET Request
```php
$req->get($url);
```
Perform a POST Request:
```php
$req->post($url, $data);
```
## Methods
The following options can be customized on constructing the object (or after construction:
1. redirects - The number of redirects to perform if a Location header is sent.
1. proxy - The proxy and port to use
1. ssl - Wether to verify the SSL certificate or not (for testing)
Also the following methods are available:
Use a Desktop User-Agent:
```php
$req->useDesktopAgent();
```
Use a Mobile User-Agent:
```php
$req->useMobileAgent();
```
Reset Headers:
```php
$req->resetHeaders();
```
Request Compression:
```php
$req->requestCompression();
```
Add a HTTP Cookie:
```php
$req->addCookie();
```