WordPress is an excellent CMS and provides a lot of flexibility for developers, users, authors, and everyone who manages websites.
I wrote a blog post phonegap few months ago and few people were interested to learn more how to use WordPress as a backend for a mobile app. Phonegap is just one of the tools you can build a mobile app. WordPress is, in this case, API server, it manages database and all the content stored in there.
It’s not that hard if you are good with PHP. All you have to do is “echo json_encode” your data, but it requires some work. And because WordPress is awesome – there are tons of plugins to do just that. One of my favorite is JSON-API. Although it hasn’t updated for couple years – it works pretty well still.
It gives you access to all the data on your site, just visit URL provided in the plugin dashboard page, URL for recent posts would “example.com/api/get_recent_posts”, need to access woocommerceproducts in json format? – No problem. Url would be “example.com/api/get_recent_products” – you get the idea… Also there is a way to authorize users and publish posts via POST request, just turn it on in plugin’s settings.
And if are developing in Chrome (like I am) – you can use great API tool like Postman to see your data nicely organized, simple, awesome.
This was very quick introduction how to get started developing WordPress and Phonegap. First thing – build WordPress site and add some content, just enough so you can see JSON structure later on. Second add JSON API plugin, configure it and make a list of all endpoints you need (recent pages, recent posts, recent custom post types, etc).
Next, I will write how to prepare phonegap for Android or iPhone (leave comments what you prefer) nad what we need next to connect Phonegap and WordPress together.
Live example of my blog in JSON format http://alexbachuk.com/api/get_recent_posts/?dev=1
Please, leave comments what you want to learn more about WordPress and JSON.