Torbjorn Zetterlund

Fri 27 2016
Image

Using WordPress instead of Parse.com

by bernt & torsten

If you have not heard it yet, Parse announced they’re shutting down their backend as a service. If you’ve built a mobile app with Parse as your backend, you need to migrate to another backend platform or set up your own parse server, as Parse is open-sourcing the parse server.

The good news is that they’re giving developers 12 months to find a new solution, and they’re providing a path to running your own Parse-compatible service. There’s a great migration guide that covers exporting Parse data to MongoDB and running a Parse server built on Node.js and express.

WordPress instead of Parse.com

I have taken a different route, instead of setting up my own parse server, I have taken the route of using WordPress as my backend. My Android app is very simple, it’s a recipe guide for cyclists.

Screenshot_20160624-163637

The app is very simple, in that it shows the recipes and you can select recipes by category. My database model requires a recipe table and a category table.

WordPress Plugins to use

To be able to emulate exactly the same data model as on the parse.com service, I needed to take the help of some specific plugins to be able to create the same database model as on the parse.com database.

What did I do

I configured the Custom Post Types UI creating a new Post Type

Add_Edit_Post_Types

When configuring I made sure that I set the REST API to true.

I then created a custom category that is linked with the Custom Post Type.

Add_Edit_Taxonomies

Make sure your REST API is set to true.

Edit_Field_Group

Next, I created my Custom Fields with Advanced Custom Fields (ACF) – 

I made sure that the post type for my custom fields is set to recipes.

Adding Recipes

Now after I set up the ACF and CP UI – I can start adding my categories,

Recipe_Categories

I wrote the plugin WP Custom Category Images to add an image for each category. After I set up my categories, I entered my recipes:

Recipes

When all was done, now I can start using my mobile app to show the content in my mobile app. To do that I needed to enable WP REST API V2 and to register my custom recipe images with the WP REST API V2, I did that by creating a plugin WP API V2 Recipe Category Images which with a few lines of code register the IP. I could have used a plugin like Code Snippets to enter the code, I went with a plugin.

Testing

I use chrome, so for testing, I’m using the chrome addon Advanced REST client – you can also test in the browser.

My Recipe API call – https://<url>/wp-json/wp/v2/recipes/

My Recipe Category API Call – https://<url>/wp-json/wp/v2/recipe_categories/

If you have any questions you can contact me or you can use the comment fields below.

Share: