KEMBAR78
Intoduction to php web services and json | PDF
Web Services with PHP
Website
• Response will be in HTML
• Accessed by humans via web browsers
User browsing websites in HTML
Application running
on Web server
HTTP request
HTML response
Web Service
• A Web service is a method of communications between two
software applications over the World Wide Web.
• Web services are Accessed by programs/Applications.
• Response will be in XML or JSON
HTTP/ SOAP / REST request
Response in XML / JSON
Another application running
on Web server
Some Application running on a
Web server
But why I should do so?
Consider the Scenario
• Suppose you have a travel and tourism application from which users will get
updates on flight timings, train timings etc
• But for this to be practical- your application must be integrated with the
applications of all the airlines(air india, Jet air, King fisher etc) and for the train
also which is almost impractical or quire a highly expensive method
• So what you do? You go to airlines website, copy the flight times available and
enter that data on your travel application, so those details will be available to
users of your application !!
Application server of emirates airlinesApplication server of your travel application
Copy the details from
airlines website
enter the details of
airlines in your travel
application
Application server of emirates airlinesApplication server of your travel application
SOAP/HTTP/REST Webservice
User get updates on the flight details from your travel application
Using Web service
Benefits of Web Service
• Exposing the existing function on to network, so that any
software's can access
• Low Cost of communication
• Connecting Different Applications ie Interoperability. This in
turns make it possible to access the data exposed by an
application(developed in any programming language say .Net) by
another application(developed in any other language say
android/IOS/PHP etc)
Webservices
Web service
in PHP
Other Platforms
Windows(c#)
Android
Web Service Data Format Types
• The following standard data format types are supported by Service
via the HTTP protocol
• SOAP
• JSON
• CSV
• EXCEL
• XML
• PDF
• RSS
Web Service Data Format Types
• The following standard data format types are supported by Service
via the HTTP protocol
• SOAP
• JSON
• CSV
• EXCEL
• XML
• PDF
• RSS
We will be learning about web services using
json as it is the advanced methodology using
in the industry
JSON
JSON
• JavaScript Object Notation.
• JSON is syntax for storing and exchanging text information.
• JSON is language independent.
• JSON uses JavaScript syntax for describing data objects.
• JSON parsers and JSON libraries exists for many different
programming languages.
JSON Objects
• JSON objects are written inside curly brackets,
– Objects can contain multiple name/values pairs:
{ "firstName":"John" , "lastName":"Doe" }
• JSON arrays are written inside square brackets.
– An array can contain multiple objects:
{"employees": [
{ "firstName":"John" , "lastName":"Doe" },
{ "firstName":"Anna" , "lastName":"Smith" },
{ "firstName":"Peter" , "lastName":"Jones" }]
}
JSON Example
<body>
<h2>JSON Object Creation in JavaScript</h2>
<p>
Name : <span id="jname"></span> <br />
Age : <span id="jage"></span> <br />
</p>
<script>
var JSONObject= {"name":"John Johnson“,"age":33};
document.getElementById("jname").innerHTML=JSONObject.name;
document.getElementById("jage").innerHTML=JSONObject.age;
</script>
</body>
JSON WEB SERVICE
• Having the JSON object available as a data format for web services
means that you can create (insert), update, and query any data in
the web service in JSON object format, and get results in the same
format
Questions?
“A good question deserve a good grade…”
Self Check !!
If this presentation helped you, please visit our
page facebook.com/baabtra and like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com

Intoduction to php web services and json

  • 1.
  • 2.
    Website • Response willbe in HTML • Accessed by humans via web browsers User browsing websites in HTML Application running on Web server HTTP request HTML response
  • 3.
    Web Service • AWeb service is a method of communications between two software applications over the World Wide Web. • Web services are Accessed by programs/Applications. • Response will be in XML or JSON HTTP/ SOAP / REST request Response in XML / JSON Another application running on Web server Some Application running on a Web server
  • 4.
    But why Ishould do so?
  • 5.
    Consider the Scenario •Suppose you have a travel and tourism application from which users will get updates on flight timings, train timings etc • But for this to be practical- your application must be integrated with the applications of all the airlines(air india, Jet air, King fisher etc) and for the train also which is almost impractical or quire a highly expensive method • So what you do? You go to airlines website, copy the flight times available and enter that data on your travel application, so those details will be available to users of your application !!
  • 6.
    Application server ofemirates airlinesApplication server of your travel application Copy the details from airlines website enter the details of airlines in your travel application
  • 7.
    Application server ofemirates airlinesApplication server of your travel application SOAP/HTTP/REST Webservice User get updates on the flight details from your travel application Using Web service
  • 8.
    Benefits of WebService • Exposing the existing function on to network, so that any software's can access • Low Cost of communication • Connecting Different Applications ie Interoperability. This in turns make it possible to access the data exposed by an application(developed in any programming language say .Net) by another application(developed in any other language say android/IOS/PHP etc)
  • 9.
    Webservices Web service in PHP OtherPlatforms Windows(c#) Android
  • 10.
    Web Service DataFormat Types • The following standard data format types are supported by Service via the HTTP protocol • SOAP • JSON • CSV • EXCEL • XML • PDF • RSS
  • 11.
    Web Service DataFormat Types • The following standard data format types are supported by Service via the HTTP protocol • SOAP • JSON • CSV • EXCEL • XML • PDF • RSS We will be learning about web services using json as it is the advanced methodology using in the industry
  • 12.
  • 13.
    JSON • JavaScript ObjectNotation. • JSON is syntax for storing and exchanging text information. • JSON is language independent. • JSON uses JavaScript syntax for describing data objects. • JSON parsers and JSON libraries exists for many different programming languages.
  • 14.
    JSON Objects • JSONobjects are written inside curly brackets, – Objects can contain multiple name/values pairs: { "firstName":"John" , "lastName":"Doe" } • JSON arrays are written inside square brackets. – An array can contain multiple objects: {"employees": [ { "firstName":"John" , "lastName":"Doe" }, { "firstName":"Anna" , "lastName":"Smith" }, { "firstName":"Peter" , "lastName":"Jones" }] }
  • 15.
    JSON Example <body> <h2>JSON ObjectCreation in JavaScript</h2> <p> Name : <span id="jname"></span> <br /> Age : <span id="jage"></span> <br /> </p> <script> var JSONObject= {"name":"John Johnson“,"age":33}; document.getElementById("jname").innerHTML=JSONObject.name; document.getElementById("jage").innerHTML=JSONObject.age; </script> </body>
  • 16.
    JSON WEB SERVICE •Having the JSON object available as a data format for web services means that you can create (insert), update, and query any data in the web service in JSON object format, and get results in the same format
  • 17.
    Questions? “A good questiondeserve a good grade…”
  • 18.
  • 19.
    If this presentationhelped you, please visit our page facebook.com/baabtra and like it. Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com
  • 20.
    Contact Us Emarald Mall(Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com