WordPress V2 REST api
@sketchlife #wordpresss
Create new project and add request component.And set GET methode for getting wordpress data to your app.
Put this url to GET component
https://www.wordpress.com/wp-json/wp/v2/posts?_embed
Here embed is getting thumbnail
try{
// Get response to array
JSONArray array = new JSONArray(_response);
for (int i = 0; i < array.length(); i++) {
JSONObject o = array.getJSONObject(i);
id = o.getString("id");
// Get id from json
title = o.getJSONObject("title").getString("rendered"); // get title from json
content = o.getJSONObject("content").getString("rendered"); // get content
link = o.getString("link"); // get link
date = o.getString("date"); // get date
slug = o.getString("slug"); // get slug simple url
map = new HashMap<>();
map.put("id", id);
map.put("title", title);
map.put("content", content);
map.put("link", link);
map.put("date", date);
map.put("slug", slug);
lmap.add(map);
}
recyclerview1.setAdapter(new Recyclerview1Adapter(lmap));
}catch(Exception e){
}
subscribe and hit bell icon Sketchlife
0 Comments