Intoduction to php web services and json

1,059 views
974 views

Published on

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,059
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
70
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Intoduction to php web services and json

  1. 1. Web Services with PHP
  2. 2. 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
  3. 3. 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
  4. 4. But why I should do so?
  5. 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. 6. 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
  7. 7. 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
  8. 8. 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)
  9. 9. Webservices Web service in PHP Other Platforms Windows(c#) Android
  10. 10. 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
  11. 11. 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
  12. 12. JSON
  13. 13. 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.
  14. 14. 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" }] }
  15. 15. 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>
  16. 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. 17. Questions? “A good question deserve a good grade…”
  18. 18. Self Check !!
  19. 19. 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
  20. 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

×