https://github.com/fabricekabongo/simplehttpclient
A very simple Http Client that works on PHP 5.3
https://github.com/fabricekabongo/simplehttpclient
http http-client php php53
Last synced: 13 days ago
JSON representation
A very simple Http Client that works on PHP 5.3
- Host: GitHub
- URL: https://github.com/fabricekabongo/simplehttpclient
- Owner: fabricekabongo
- License: mit
- Created: 2017-03-02T08:12:27.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-08T08:48:07.000Z (almost 9 years ago)
- Last Synced: 2025-05-31T23:15:26.376Z (8 months ago)
- Topics: http, http-client, php, php53
- Language: PHP
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# simplehttpclient
A very simple Http Client that works on PHP 5.3
## Installation
To install simply run this :
```bash
composer require fabricekabongo/simplehttpclient
```
## Usage
This client offers 3 interfaces:
### Get request
without query parameters:
```php
$client = new FabriceKabongo\Http\HttpClient();
$responseData = $client->get('http://www.google.com');
```
or with query parameters:
```php
$client = new FabriceKabongo\Http\HttpClient();
$responseData = $client->get('http://www.google.com', array('q' => 'tallest falls in africa');//http://www.google.com?q=tallest%20falls%20in%20africa
```
### post Request
with post parameters:
```php
$client = new FabriceKabongo\Http\HttpClient();
$responseData = $client->post('http://www.myawesomeapi.com', array('foo' => 'bar');
```
### base64 upload
sends a file using base64 content (think android developers lol):
```bash
touch myfile.txt && echo "random content" > myfile.txt
```
then:
```php
$client = new FabriceKabongo\Http\HttpClient();
try {
$responseData = $client->base64Upload('http://www.myawesomeapi.com', __DIR__."/myfile.txt");
} catch (\Exception $ex) {
//log oups
}
```
## other informations
This code need php-curl to be installed (obviously you choose php5.3-curl, php5.6-curl php7.0-curl depending of your version)
# License
MIT. you are free dude.