PHP Classes

File: test.php

Recommend this page to a friend!
  Classes of Haseeb Ahmad Basil   Mega REST API Wrapper   test.php   Download  
File: test.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Mega REST API Wrapper
Call REST APIs using the Curl library
Author: By
Last change: Namespace
Date: 5 years ago
Size: 965 bytes


Class file image Download
include 'vendor/autoload.php';

$url = "";

$raw = new raw\restApiWrapper($url);

//Sending a POST Request, with Params, custom headers and return type Json decoded Object
$request1 = $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


//Sending a GET Request, without any params or custom headers and return will be a string
$request2 = $raw->get('ufkbi1uf', [], [], '');


//Sending a OPTIONS Request, with params, but no custom headers and return will be a string
$request3 = $raw->options('ufkbi1uf', ['name' => 'basil'], [], '');