PHP Web Services: APIs for the Modern Web

PHP Web Services: APIs for the Modern Web

Language: English

Pages: 180

ISBN: 1491933097

Format: PDF / Kindle (mobi) / ePub


Whether you’re sharing data between two internal systems or building an API so that users can access their data, this practical guide has everything you need to build APIs with PHP. Author Lorna Jane Mitchell provides lots of hands-on code samples, real-world examples, and advice based on her extensive experience to guide you through the process—from the underlying theory to methods for making your service robust.

You’ll learn how to use this language to work with JSON, XML, and other web service technologies. This updated second edition includes new tools and features that reflect PHP updates and changes on the Web.

  • Explore HTTP, from the request/response cycle to its verbs, headers, and cookies
  • Work with and publish webhooks—user-defined HTTP callbacks
  • Determine whether JSON or XML is the best data format for your application
  • Get advice for working with RPC, SOAP, and RESTful services
  • Use several tools and techniques for debugging HTTP web services
  • Choose the service that works best for your application, and learn how to make it robust
  • Document your API—and learn how to design it to handle errors

Learning Firefox OS Application Development

Getting Started with nopCommerce

HTML, XHTML, and CSS For The Absolute Beginner

The Mobile Book (By Smashing Magazine)

The Truth About HTML5 (For Web Designers)

The Principles of Beautiful Web Design (3rd Edition)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

the lens needed to scrutinize any decision. 3. Not every piece of data or possible piece of functionality in an application will necessarily make sense exposed over an API, so don’t be tempted to build something huge immediately! 79 Service Type Decisions The first decision to make when designing any API is one that can’t be changed: decide what kind of a service you will offer. This depends on a combination of the audience and the type of service to be created. For users who have larger

returning information about a particular item, should all the information be returned? And the follow up question: Should any related data be returned also? Including data means we’ll sometimes be returning more information than needed, a bit like doing SELECT * FROM … in SQL. But if you omit data, then some consumers will have to make a large number of requests to obtain what they need. Consider the example of the classic blog application. Should the API return the body of every article? If

information). Alongside the information about errors, you may also like to include some support information. API Documentation In the RPC services, it is common for the entry points to the service to be contained in a single class, and hopefully that class will have inline code documentation. If it does, and especially if this service is for an internal or technical audience, it may be possible to generate API documentation using phpDocumentor and supply this as a reference to your users (see

Pick Your Defaults 83 11. Building a Robust Service. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 Consistency Is Key Consistent and Meaningful Naming Common Validation Rules Predictable Structures Making Design Decisions for Robustness 85 86 86 87 88 12. Error Handling in APIs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 Output Format Meaningful Error Messages What

client and as a server. When using other verbs, either those that already exist as part of the HTTP spec or those that are custom to your application, you can use the approaches described here for PUT and DELETE. Using Other HTTP Verbs | 17 CHAPTER 3 Headers So far, we’ve seen various presentations of the HTTP format, and examined the idea that there is a lot more information being transferred in web requests and responses than what appears in the body of the response. The body is

Download sample

Download