SoftwareQuery
Home About Contact

Create a RESTful Web Service in PHP

 SoftwareQuery     2 comments   



What is Restful API?

Restful API is a Representational state transfer Application Programming Interface. If we are sending HTML request in the server via  API sever give a information in a JSON or XML form. Jason or XML why because those are structure data. It is using various type of HTTP Method. GET,PUT,POST,DELETE.We are also using a SOAP. SOAP is a simple object access protocol.IT is also implementing web services and exchanging data information.RestAPI it is most powerful and very fast. The most popular big company like Amazon, Google, Twitter, Yahoo using Restful API. API also used cloud services.


Step-1. Go to notepad++ or sublime then create a function.php page and save a page XAMPP or WampServer. the htdoc folder in XAMPP or www folder in WAMP on localhost.

<?php

function get_price($find)
{
$softwarequery=array(
         "website"=>299,
          "blogger"=>348,
           "page "=>267
);
foreach($softwarequery as $Query=>$price)
{
   if($Query==$find)
    {
    return $price;
     break;
}
}
}
Step-2. Create a index.php page and save a page XAMPP or WAMP sever htdoc folder in XAMPP or www folder in WAMP on localhost.

<?php
header("content-Type:application/json");
include("function.php");
if(!empty($_GET['name']))
{
$name= $_GET['name'];
$price= get_price($name);

if (empty($price))

 deliver_response(200,"blogger  found",$price);

else

deliver_response(200,"website found",$price);

}
else
{
deliver_response(400,"page not found",Null);

}

function deliver_response($status,$status_message,$data)
{
header("HTTP/1.1 $status $status_message");
$response['status']=$status;
$response['status_message']=$status_message;
$response['data']=$data;
$json_response=json_encode($response);
echo $json_response;


}
?>
OUTPUT-




  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to TwitterShare to Facebook
Newer Post Older Post Home

2 comments:

  1. Unknown24 July 2018 at 20:41

    thanks to give me these information

    ReplyDelete
    Replies
      Reply
  2. Anonymous21 June 2019 at 15:12

    Search engine optimization is actually the method of getting greater placement in the organic
    search results page of Google, Yahoo and also MSN. The online search engine
    that matter the best are Google.com with a 62% advertising and marketing portion Yahoo
    along with twenty% and also MSN drifting all around along with around 10% in market portion 'that means the internet search
    engine you must select is Google.com cause Google.com undoubtedly has the highest percent of individuals are looking on the net.

    ReplyDelete
    Replies
      Reply
Add comment
Load more...

Donate

Translate

Popular Posts

  • How to Make Image Upload Code Using AJAX
    Direct Copy Paste PHP File  Image Upload Code -   <html> <head> <meta charset="utf-8"> <meta http-equi...
  • Best Useful Free Plugin to Make Wordpress Theme
    Meta Slider   - Meta Slider is that the initial free possibility on today’s list. A premium version is additionally obtainable...
  • How To Install Magento on Localhost XAMPP OR WAMP SERVER
      Step-1 => Make Sure you have to install Latest Version of  Xampp server or Wamp server in your PC.   Step -2 => Go to Web Bro...
  • How To Intall Node.js Via Command On Window And Linux.
    Step-1 . Firstly We have to go official website of https://nodejs.org/en/ then download the latest version of Nodejs zi...
  • How to Set up Amazon Affiliate Marketing Account to Earn Money
    Amazon Associates is a  marketing of Amazon company. It is allowed to youtube channel owner, Social Media pages owner and any type...
  • How To Create Custom Pagination In WordPress
    Hello, Friend's in this post we are creating a custom code of Pagination in WordPress. It is very easy to put this code any custom...
  • How to create facebook share and like button for webpage
    Step-1 . Go to web browser type google and write facebook sharing button click this URL or open this URL.                     Ref URL:...
  • How To Scrape Data From Website Url Using Php.
    Q. why using a Scraping. If we want to get data of another website then using web scraping. It is using a PHP HTML Dom parser library ...
  • How To Install Wordpress in Xampp Server And Wamp Server
      Step 1st  -      Install WampServer or Xampp Server.                                                                               ...
  • Upload Multiple Images to Firebase Storage with Angular
    Step-1 . Create a new Angular Project open command window then write a command.                     #ng new UploadImageApp Step-2 ....

Home

This blog Is very help full for beginner coder,if you want to learn new things definitely this Blog is very
helpful for you guys.

Followers

Contact form

Name

Email *

Message *

Blog

  • Home
  • About Us
  • Privacy Policy
  • Disclaimer
  • Contact Us
  • Terms&Conditions

NewsLetter

Copyright © SoftwareQuery | Powered by softwarequery
Design by ShubhamTiwari | Theme by softwarequery.com | Distributed By softwarequery/