Android development: Getting data from WordPress

10,451

Solution 1

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

Solution 2

I ended up with writing my own JSON.

Share:
10,451
fuiiii
Author by

fuiiii

Updated on June 09, 2022

Comments

  • fuiiii
    fuiiii almost 2 years

    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

  • fuiiii
    fuiiii over 10 years
    Thanks for your response! You mean I could use the JSON-API plugin for getting wordpress data as JSON form and use Volley,ect to get the data (which is in the form of JSON) to my app? Is the JSON-API could get me data from any website based on WordPress or only my own website?
  • Ajeet47
    Ajeet47 over 10 years
    yes we can get data from any website which is wordpress based and json-api plug-in installed on it. basically json-api convert your HTML content into json format striping all html(css,javascript,html tags ) code give only text data and image URLs
  • fuiiii
    fuiiii over 10 years
    I have got my wordpress website and install the json-api plug-in. But I don't know how to get the json format data from it. What should I type into my browser to view the json format of my web? thank!!
  • Marian Paździoch
    Marian Paździoch over 9 years
    that's bad approach, but you'll find it sometime in the future