https://github.com/devawal/restful-curl-php
Restful CURL for PHP application
https://github.com/devawal/restful-curl-php
Last synced: 4 months ago
JSON representation
Restful CURL for PHP application
- Host: GitHub
- URL: https://github.com/devawal/restful-curl-php
- Owner: devawal
- License: mit
- Created: 2017-07-20T08:55:49.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-23T11:33:54.000Z (almost 9 years ago)
- Last Synced: 2025-10-19T15:42:53.894Z (9 months ago)
- Language: PHP
- Homepage: https://abdulawal.me
- Size: 9.77 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Restful CURL for PHP application
### Install
It's recommended that you use [Composer](https://getcomposer.org/) to install restful-curl-php
```bash
$ composer require devawal/restful-curl
```
### Description
```php
object|array RestCurl::get(string $url, array $parameters, boolean $json_post, array $header, boolean $object)
```
### Parameters
* url: Request URL
* parameters: Request parameters
* json_post: If the request parameters is json
* header: Request with header
* object: If response needs to be object
### Usage
```php
require 'vendor/autoload.php';
use RestfullCurl\RestCurl;
// Get request
$response = RestCurl::get('https://jsonplaceholder.typicode.com/posts');
// Post request
$response = RestCurl::post('https://jsonplaceholder.typicode.com/posts');
// Post request with parameters and header
$param = array(
'grant_type'=>'password',
'client_secret'=>'s5df5d6f6d6f',
);
$header = array('Accept: application/json', 'Authorization: Bearer df98df665df6d8f8');
$response = RestCurl::post('https://jsonplaceholder.typicode.com/posts', $parameters, true, $header);
// Put request
$response = RestCurl::put('https://jsonplaceholder.typicode.com/posts/1');
// Patch request
$response = RestCurl::patch('https://jsonplaceholder.typicode.com/posts/1');
// Delete request
$response = RestCurl::delete('https://jsonplaceholder.typicode.com/posts/1');
```