REST API
Simple Introduction of REST API
In the IT field REST API or API is the most important magical word.So, by this blog I'm going to touch that magical topic.
REST API (Representational State Transfer) is one of the easiest way of accessing web services.
It is a concept or architecture for managing information over the Internet.
API(Application Programming Interface). It is a set or rules which allows one piece of software application to talk to another.
Following "rules" can include into he REST API
API s created by many languages such as NODEjs, JAVA, PHP and etc.
From this blog I'm going to describe PHP REST API.
REST API creation Steps
Step1 : Use xammp server and phpMyadmin to create database,tables and its data.
Step2 : Connect your database.
Step3 : Write CRUD operation for your site.
Step4 : Each and every CRUD operations are encoded by JSON (JavaScript Object Notation).
How to call API
Before I go to Steps I'm going to briefly explain how will be displayed url when we query some data in browser.
Ex:
Step1 : Define url
It is a concept or architecture for managing information over the Internet.
REST API architecture |
API(Application Programming Interface). It is a set or rules which allows one piece of software application to talk to another.
Following "rules" can include into he REST API
- Create
- Read
- Update and
- Delete operations.
- HTTP GET or
- HTTP POST or
- HTTP DELETE or
- HTTP PUT request from the client side to the server to get or to put some information to the server.
API s created by many languages such as NODEjs, JAVA, PHP and etc.
From this blog I'm going to describe PHP REST API.
REST API creation Steps
Step1 : Use xammp server and phpMyadmin to create database,tables and its data.
Step2 : Connect your database.
Step3 : Write CRUD operation for your site.
Step4 : Each and every CRUD operations are encoded by JSON (JavaScript Object Notation).
How to call API
Before I go to Steps I'm going to briefly explain how will be displayed url when we query some data in browser.
Ex:
- https://www.google.com/search?client=ubuntu
- https://www.facebook.com/Puradsifm/?hc_ref=ARQC2_B8Qmj
Step1 : Define url
$url = "http://localhost/RESTAPI/api/product/read_one.php?id=".$id;Step2 : Initialize the url
$client = curl_init($url);
Step3 : Setting the option for urlcurl_setopt($client,CURLOPT_RETURNTRANSFER,true);Step4 : Execution the url
$response = curl_exec($client);
Step5 : decode the JSON code which is encode in the API$result = json_decode($response);
Step6 : Release the urlcurl_close($ch);Step7 : Print the output
print_r($result);
This is the most simple way to call PHP API.
On my next post I'll Explain how to create CRUD operation using PHP
Comments