Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android development: Getting data from WordPress

I'm making an android app for displaying some school events(Title of the event and a posted picture of the event).

The only thing I need for the app is getting data(String for title, ImageView for the picture)from a server.

The answer of this post, Android Development : Getting data from the web, seems to be the easiest and the most straight forward way I could find.

"The easiest way to display posts into an Android application will be to use JSON data on the web, and read it into a Master Detail Android application.

On the website side, getting the data to display in JSON seems to be the most difficult part of your problem. It would be easy if it was a Wordpress site, as there are plugins that will do this for you.

On the application side, getting the data and parsing it into a master detail flow is a fairly trivial task."

I know almost nothing about database, networking, wordpress, and JSON. :(

I have made an wordpress account and install the JSON plugin and wordpress web server plugin. But that's how far I could get :(

My idea is

in the wordpress blog site: make a post for each new event. The title of the post is the event title and the content of the post just a picture, which is a post about the event.

in the app side: add a synchronize task within the onCreate function, so when the app is opened, it will check if there's any new post in the blog. If there's any, it will get the blog title and add to the listView, and get the picture inside of the blog and create a new layout in which has a ImageView for holding the picture.

As I said, I know nothing about web service and networking.

I have no clue about how to check if there's any new post in the blog comparing with those events already in the app.....

These two examples are the closet I could get.

http://android.programmerguru.com/android-webservice-example/ http://wordpress.org/support/topic/phonegap-android-app-built-around-json-api (I don't understand this one! :/)

Please help! This thing is giving me a big headache! And it's the last step I need for the app!

Any help or sample code will be greatly appreciated!!

And most importantly, Merry Christmas, everyone! XD

like image 277
fuiiii Avatar asked Dec 24 '13 04:12

fuiiii


2 Answers

There is Wordpress plug-in called JSON-API it gives you ability to access every object of Wordpress( post ,page ,category.. etc ) in the form of JSON. you can use any rest client like volley from google, retrofit from Square or build your won to access wordpress data.

install Wordpress plug-in http://wordpress.org/plugins/json-api/

for sample code you can look Wordpress for android source code on github https://github.com/wordpress-mobile/WordPress-Android

like image 197
Ajeet47 Avatar answered Nov 15 '22 09:11

Ajeet47


I ended up with writing my own JSON.

like image 45
fuiiii Avatar answered Nov 15 '22 10:11

fuiiii