codingtcher.com
Theme Night
Home
Login

How to Create a Simple API in Php

Home » Tutorial Post » How to Create a Simple API in Php
<?php
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET');
header('Access-Control-Allow-Headers: Access-Control-Allow-Headers,Content-Type,Access-Control-Allow-Methods,Access-Control-Allow-Origin, Authorization, X-Requested-With');
//header('Access-Control-Allow-Headers: Access-Control-Allow-Headers,Content-Type,Access-Control-Allow-Methods,Access-Control-Allow-Origin, Authorization');


if(!isset($_GET['secretcode']) || $_GET['secretcode']!="mycode50"){
    die(json_encode(array('message' => 'something went wrong!', 'statusmsg' => false)));
}

echo "php rest api is working..."
//die(json_encode(array('message' => '', 'statusmsg' => true)));

?>

Related Post