What is the best API technique?

There are many ways to connect a mobile app with a web site. Each technique has its own pros and cons. To cite an excellent book, Web API Design, by Brian Mulloy, is a modern source of current successfully approaches.

In the most common scenario, mobile apps for Joomla! open an AJAX connection to submit and retrieve information.

What's AJAX?

AJAX stands for Asynchronous JavaScript and XML. In a nutshell, it is the use of the XMLHttpRequest >object to communicate with server-side scripts. It can send as well as receive information in a >variety of formats, including JSON, XML, HTML, and even text files. AJAX’s most appealing >characteristic, however, is its "asynchronous" nature, which means it can do all of this without >having to refresh the page. This lets you update portions of a page based upon user events.

AJAX communication can implement a simple HTTP POST - GET API or any API based on JSON communication. Furthermore, this technique is heavily used in most extensions and web development. Due to all of these reasons, JoomGap SDK is sided on AJAX / JSON communication.

A mobile app, based on PhoneGap, is a native client accessing your site. As a consequence, it is not limited by Cross-origin restrictions.

On the other hand, your development browser is restricted as usual. Then, a solution for cross-development is desired. JoomGap SDK supports a basic REST (JSON) and JSONP protocol to ease the development in a desktop setup and support all possible use cases. More about CORS: Joomla and Cross-Origin Resource Sharing (CORS)

Concerning to JSONP: please, take into account that JSONP API has a different security profile than a standard JSON API. For more information: Security risks with JSONP?

Finally, there are other ways to enable external client access, but they require ad-hoc htaccess configuration and browser compatibility checks to disable security measures for each specific client.

PhoneGap apps have several alternative protocols to communicate. For instance, WebSockets or native sockets. However, these options are of limited usage in the general case of a Joomla! CMS running in a LAMP architecture.

We welcome feedback! Leave a comment by clicking the icon in upper right corner of the banner.