PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Haseeb Ahmad Basil   Mega REST API Wrapper   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: Mega REST API Wrapper
Call REST APIs using the Curl library
Author: By
Last change: Update README.md
Update README.md
Update README.md
Date: 6 years ago
Size: 1,133 bytes
 

Contents

Class file image Download

restApiWrapper

A Curl Wrapper for RESTful APIs

To Install use composer:

composer require mega6382/rest-api-wrapper

Quick Examples

Create a restApiWrapper instance

$url = "https://example.com/";
$raw = new raw\restApiWrapper($url);

Send a POST Request, with Params, Custom Headers and Return type Json Object

$request = $raw->post(
            'ufkbi1uf', // Endpoint to the API
            [ //POST Params
                'param1' => 'abc',
                'param2' => 'def',
                'param3' => 'ghi',
            ],
            [ //Request Headers 
                'Content-Type: application/xml',
                'Connection: Keep-Alive'
            ],
            'json' //Return type
        );
var_dump($request);

Send a GET Request, without any Params or Custom Headers and return String

$request = $raw->get('ufkbi1uf', [], [], '');
var_dump($request);

Send a OPTIONS Request, with Params, but no Custom headers and return will be a string

$request = $raw->options('ufkbi1uf', ['name' => 'basil'], [], '');
var_dump($request);