In the case of sending back data from Wordpress to an Android application using JSON, APi Plugin is very bad , although it gives the expected results, but have you really seen what the result of the json request is?
Just check it, enter in your browser: www.yourwebsite.com/api/get_posts/
and check what you get, this will request all the messages or the number of messages that you set by default in your Wordpress panel and send all the data about them as a json string, I tried to request 10 messages and the size from the json string was about 150 KB to submit a total of 10 messages, the user will have to download all of them each time to receive a total of 10 messages.
Decision. You should request messages on the server side and send back to the Android application only the data that you are going to use, for example: name, thumbnail, shutter speed ....
How to do it?
1- Make php file in your wordpress directory and make it available
2- receive published values ββfrom android in it (they will be set by you in android to find out the type of the requested request, for example, the number of messages and the type of messages ...)
3 message-messages using wordpress functions in accordance with entites request in part-2
4- Create your own json string only with the data you want to use.
5 repeat json string back to android
Now, if I only need a title and a thumbnail of 10 posts, the json string size will be approximately 2KB
what matters :-)
You can use the Auth JSON API to register and login, which is easy or fast to implement and use.
Salam el-banna
source share