Guest User

Untitled

a guest
Oct 22nd, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.58 KB | None | 0 0
  1. {
  2. "status": "ok",
  3. "count": 1,
  4. "pages": 1,
  5. "category": {
  6. "id": 44,
  7. "slug": "flex-print",
  8. "title": "Flex Print",
  9. "description": "Flex Print",
  10. "parent": 7,
  11. "post_count": 1
  12. },
  13. "posts": [
  14. {
  15. "id": 343,
  16. "type": "post",
  17. "slug": "nk-advertising",
  18. "url": "https://btownmedia.com/2018/10/10/nk-advertising/",
  19. "status": "publish",
  20. "title": "NK Advertising",
  21. "title_plain": "NK Advertising",
  22. "content": "<p style="color: #7a6666; font-family: roboto-regular-webfont; font-size: 14px; line-height: 24px; margin: 0px; padding: 0px 0px 19px; width: 370px;"><strong>Online advertisement:</strong> <em>Online advertisement on our website</em> means our basic service. Your business card or a visiting card sized advertisement is displayed on our website for pre-mentioned time frame.</p>n<p style="color: #7a6666; font-family: roboto-regular-webfont; font-size: 14px; line-height: 24px; margin: 0px; padding: 0px 0px 19px; width: 370px;"><strong>Personalized page:</strong> We offer you a personalized page, designed for your business with all the details of your business- linked with your advertisement that opens when clicked.</p>n",
  23. "excerpt": "<p>Online advertisement on our website means our basic service. Your business card or a visiting card sized advertisement is displayed on our website for pre-mentioned time frame.</p>n",
  24. "date": "2018-10-10 08:08:29",
  25. "modified": "2018-10-10 08:08:29",
  26. "categories": [
  27. {
  28. "id": 44,
  29. "slug": "flex-print",
  30. "title": "Flex Print",
  31. "description": "Flex Print",
  32. "parent": 7,
  33. "post_count": 1
  34. }
  35. ],
  36. "tags": [],
  37. "author": {
  38. "id": 1,
  39. "slug": "admin",
  40. "name": "admin",
  41. "first_name": "",
  42. "last_name": "",
  43. "nickname": "admin",
  44. "url": "",
  45. "description": ""
  46. },
  47. "comments": [],
  48. "attachments": [
  49. {
  50. "id": 342,
  51. "url": "https://btownmedia.com/nk/",
  52. "slug": "nk",
  53. "title": "nk",
  54. "description": "",
  55. "caption": "",
  56. "parent": 343,
  57. "mime_type": "image/png",
  58. "images": {
  59. "full": {
  60. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  61. "width": 230,
  62. "height": 142
  63. },
  64. "thumbnail": {
  65. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk-150x142.png",
  66. "width": 150,
  67. "height": 142
  68. },
  69. "medium": {
  70. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  71. "width": 230,
  72. "height": 142
  73. },
  74. "medium_large": {
  75. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  76. "width": 230,
  77. "height": 142
  78. },
  79. "large": {
  80. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  81. "width": 230,
  82. "height": 142
  83. },
  84. "rpggallery_admin_thumb": {
  85. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  86. "width": 230,
  87. "height": 142
  88. },
  89. "rpggallery_admin_large": {
  90. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  91. "width": 230,
  92. "height": 142
  93. },
  94. "rpg_gallery_admin_thumb": {
  95. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk-150x142.png",
  96. "width": 150,
  97. "height": 142
  98. },
  99. "rpg_gallery_thumb": {
  100. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk-150x142.png",
  101. "width": 150,
  102. "height": 142
  103. },
  104. "estore-featured-image": {
  105. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  106. "width": 230,
  107. "height": 142
  108. },
  109. "estore-product-grid": {
  110. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk-75x75.png",
  111. "width": 75,
  112. "height": 75
  113. },
  114. "estore-square": {
  115. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  116. "width": 230,
  117. "height": 142
  118. },
  119. "estore-slider": {
  120. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  121. "width": 230,
  122. "height": 142
  123. },
  124. "estore-medium-image": {
  125. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  126. "width": 230,
  127. "height": 142
  128. }
  129. }
  130. }
  131. ],
  132. "comment_count": 0,
  133. "comment_status": "open",
  134. "thumbnail": "https://btownmedia.com/wp-content/uploads/2018/10/nk-150x142.png",
  135. "custom_fields": {},
  136. "thumbnail_size": "thumbnail",
  137. "thumbnail_images": {
  138. "full": {
  139. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  140. "width": 230,
  141. "height": 142
  142. },
  143. "thumbnail": {
  144. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk-150x142.png",
  145. "width": 150,
  146. "height": 142
  147. },
  148. "medium": {
  149. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  150. "width": 230,
  151. "height": 142
  152. },
  153. "medium_large": {
  154. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  155. "width": 230,
  156. "height": 142
  157. },
  158. "large": {
  159. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  160. "width": 230,
  161. "height": 142
  162. },
  163. "rpggallery_admin_thumb": {
  164. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  165. "width": 230,
  166. "height": 142
  167. },
  168. "rpggallery_admin_large": {
  169. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  170. "width": 230,
  171. "height": 142
  172. },
  173. "rpg_gallery_admin_thumb": {
  174. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk-150x142.png",
  175. "width": 150,
  176. "height": 142
  177. },
  178. "rpg_gallery_thumb": {
  179. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk-150x142.png",
  180. "width": 150,
  181. "height": 142
  182. },
  183. "estore-featured-image": {
  184. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  185. "width": 230,
  186. "height": 142
  187. },
  188. "estore-product-grid": {
  189. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk-75x75.png",
  190. "width": 75,
  191. "height": 75
  192. },
  193. "estore-square": {
  194. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  195. "width": 230,
  196. "height": 142
  197. },
  198. "estore-slider": {
  199. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  200. "width": 230,
  201. "height": 142
  202. },
  203. "estore-medium-image": {
  204. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  205. "width": 230,
  206. "height": 142
  207. }
  208. }
  209. }
  210. ]
  211.  
  212. private Integer id;
  213. private String type;
  214. private String slug;
  215. private String url;
  216. private String status;
  217. private String title;
  218. private String titlePlain;
  219. private String content;
  220. private String excerpt;
  221. private String date;
  222. private String modified;
  223. private List<Object> tags = null;
  224. private List<Object> comments = null;
  225. private Integer commentCount;
  226. private String commentStatus;
  227. private String thumbnail;
  228. private String thumbnailSize;
  229.  
  230. public Integer getId() {
  231. return id;
  232. }
  233.  
  234. public void setId(Integer id) {
  235. this.id = id;
  236. }
  237.  
  238. public String getType() {
  239. return type;
  240. }
  241.  
  242. public void setType(String type) {
  243. this.type = type;
  244. }
  245.  
  246. public String getSlug() {
  247. return slug;
  248. }
  249.  
  250. public void setSlug(String slug) {
  251. this.slug = slug;
  252. }
  253.  
  254. public String getUrl() {
  255. return url;
  256. }
  257.  
  258. public void setUrl(String url) {
  259. this.url = url;
  260. }
  261.  
  262. public String getStatus() {
  263. return status;
  264. }
  265.  
  266. public void setStatus(String status) {
  267. this.status = status;
  268. }
  269.  
  270. public String getTitle() {
  271. return title;
  272. }
  273.  
  274. public void setTitle(String title) {
  275. this.title = title;
  276. }
  277.  
  278. public String getTitlePlain() {
  279. return titlePlain;
  280. }
  281.  
  282. public void setTitlePlain(String titlePlain) {
  283. this.titlePlain = titlePlain;
  284. }
  285.  
  286. public String getContent() {
  287. return content;
  288. }
  289.  
  290. public void setContent(String content) {
  291. this.content = content;
  292. }
  293.  
  294. public String getExcerpt() {
  295. return excerpt;
  296. }
  297.  
  298. public void setExcerpt(String excerpt) {
  299. this.excerpt = excerpt;
  300. }
  301.  
  302. public String getDate() {
  303. return date;
  304. }
  305.  
  306. public void setDate(String date) {
  307. this.date = date;
  308. }
  309.  
  310. public String getModified() {
  311. return modified;
  312. }
  313.  
  314. public void setModified(String modified) {
  315. this.modified = modified;
  316. }
  317.  
  318.  
  319.  
  320. public List<Object> getTags() {
  321. return tags;
  322. }
  323.  
  324. public void setTags(List<Object> tags) {
  325. this.tags = tags;
  326. }
  327.  
  328.  
  329.  
  330. public List<Object> getComments() {
  331. return comments;
  332. }
  333.  
  334. public void setComments(List<Object> comments) {
  335. this.comments = comments;
  336. }
  337.  
  338.  
  339.  
  340. public Integer getCommentCount() {
  341. return commentCount;
  342. }
  343.  
  344. public void setCommentCount(Integer commentCount) {
  345. this.commentCount = commentCount;
  346. }
  347.  
  348. public String getCommentStatus() {
  349. return commentStatus;
  350. }
  351.  
  352. public void setCommentStatus(String commentStatus) {
  353. this.commentStatus = commentStatus;
  354. }
  355.  
  356. public String getThumbnail() {
  357. return thumbnail;
  358. }
  359.  
  360. public void setThumbnail(String thumbnail) {
  361. this.thumbnail = thumbnail;
  362. }
  363.  
  364.  
  365.  
  366. public String getThumbnailSize() {
  367. return thumbnailSize;
  368. }
  369.  
  370. public void setThumbnailSize(String thumbnailSize) {
  371. this.thumbnailSize = thumbnailSize;
  372. }
  373.  
  374. @GET("json=get_category_posts&slug=flex-print&status=publish")
  375. Call<Post> getListPost();
  376.  
  377. void getListPosts() {
  378.  
  379. Retrofit retrofit = new Retrofit.Builder()
  380. .baseUrl(url1)
  381. .addConverterFactory(GsonConverterFactory.create())
  382. .build();
  383.  
  384. RetrofitArrayAPI service = retrofit.create(RetrofitArrayAPI.class);
  385. Log.d("service", String.valueOf(""));
  386.  
  387. Call<Post> call = service.getListPost();
  388.  
  389. call.enqueue(new Callback<Post>() {
  390. @Override
  391. public void onResponse(Response<Post> response, Retrofit retrofit) {
  392.  
  393. try {
  394.  
  395. Log.d("Title", String.valueOf(response.body()));
  396.  
  397.  
  398. } catch (Exception e) {
  399. Log.d("onResponse", "There is an error");
  400. e.printStackTrace();
  401. }
  402.  
  403. }
  404.  
  405. @Override
  406. public void onFailure(Throwable t) {
  407. Log.d("onFailure", t.toString());
  408. }
  409. });
  410. }
  411.  
  412. "posts": [
  413. {
  414. "id": 343,
  415. "type": "post",
  416. "slug": "nk-advertising",
  417. "url": "https://btownmedia.com/2018/10/10/nk-advertising/",
  418. "status": "publish",
  419. "title": "NK Advertising",
  420. "title_plain": "NK Advertising",
  421. "content": "<p style="color: #7a6666; font-family: roboto-regular-webfont; font-size: 14px; line-height: 24px; margin: 0px; padding: 0px 0px 19px; width: 370px;"><strong>Online advertisement:</strong> <em>Online advertisement on our website</em> means our basic service. Your business card or a visiting card sized advertisement is displayed on our website for pre-mentioned time frame.</p>n<p style="color: #7a6666; font-family: roboto-regular-webfont; font-size: 14px; line-height: 24px; margin: 0px; padding: 0px 0px 19px; width: 370px;"><strong>Personalized page:</strong> We offer you a personalized page, designed for your business with all the details of your business- linked with your advertisement that opens when clicked.</p>n",
  422. "excerpt": "<p>Online advertisement on our website means our basic service. Your business card or a visiting card sized advertisement is displayed on our website for pre-mentioned time frame.</p>n",
  423. "date": "2018-10-10 08:08:29",
  424. "modified": "2018-10-10 08:08:29",
  425. "categories": [
  426. {
  427. "id": 44,
  428. "slug": "flex-print",
  429. "title": "Flex Print",
  430. "description": "Flex Print",
  431. "parent": 7,
  432. "post_count": 1
  433. }
  434. ],
  435. "tags": [],
  436. "author": {
  437. "id": 1,
  438. "slug": "admin",
  439. "name": "admin",
  440. "first_name": "",
  441. "last_name": "",
  442. "nickname": "admin",
  443. "url": "",
  444. "description": ""
  445. },
  446. "comments": [],
  447. "attachments": [
  448. {
  449. "id": 342,
  450. "url": "https://btownmedia.com/nk/",
  451. "slug": "nk",
  452. "title": "nk",
  453. "description": "",
  454. "caption": "",
  455. "parent": 343,
  456. "mime_type": "image/png",
  457. "images": {
  458. "full": {
  459. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  460. "width": 230,
  461. "height": 142
  462. },
  463. "thumbnail": {
  464. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk-150x142.png",
  465. "width": 150,
  466. "height": 142
  467. },
  468. "medium": {
  469. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  470. "width": 230,
  471. "height": 142
  472. },
  473. "medium_large": {
  474. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  475. "width": 230,
  476. "height": 142
  477. },
  478. "large": {
  479. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  480. "width": 230,
  481. "height": 142
  482. },
  483. "rpggallery_admin_thumb": {
  484. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  485. "width": 230,
  486. "height": 142
  487. },
  488. "rpggallery_admin_large": {
  489. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  490. "width": 230,
  491. "height": 142
  492. },
  493. "rpg_gallery_admin_thumb": {
  494. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk-150x142.png",
  495. "width": 150,
  496. "height": 142
  497. },
  498. "rpg_gallery_thumb": {
  499. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk-150x142.png",
  500. "width": 150,
  501. "height": 142
  502. },
  503. "estore-featured-image": {
  504. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  505. "width": 230,
  506. "height": 142
  507. },
  508. "estore-product-grid": {
  509. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk-75x75.png",
  510. "width": 75,
  511. "height": 75
  512. },
  513. "estore-square": {
  514. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  515. "width": 230,
  516. "height": 142
  517. },
  518. "estore-slider": {
  519. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  520. "width": 230,
  521. "height": 142
  522. },
  523. "estore-medium-image": {
  524. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  525. "width": 230,
  526. "height": 142
  527. }
  528. }
  529. }
  530. ],
  531. "comment_count": 0,
  532. "comment_status": "open",
  533. "thumbnail": "https://btownmedia.com/wp-content/uploads/2018/10/nk-150x142.png",
  534. "custom_fields": {},
  535. "thumbnail_size": "thumbnail",
  536. "thumbnail_images": {
  537. "full": {
  538. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  539. "width": 230,
  540. "height": 142
  541. },
  542. "thumbnail": {
  543. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk-150x142.png",
  544. "width": 150,
  545. "height": 142
  546. },
  547. "medium": {
  548. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  549. "width": 230,
  550. "height": 142
  551. },
  552. "medium_large": {
  553. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  554. "width": 230,
  555. "height": 142
  556. },
  557. "large": {
  558. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  559. "width": 230,
  560. "height": 142
  561. },
  562. "rpggallery_admin_thumb": {
  563. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  564. "width": 230,
  565. "height": 142
  566. },
  567. "rpggallery_admin_large": {
  568. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  569. "width": 230,
  570. "height": 142
  571. },
  572. "rpg_gallery_admin_thumb": {
  573. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk-150x142.png",
  574. "width": 150,
  575. "height": 142
  576. },
  577. "rpg_gallery_thumb": {
  578. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk-150x142.png",
  579. "width": 150,
  580. "height": 142
  581. },
  582. "estore-featured-image": {
  583. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  584. "width": 230,
  585. "height": 142
  586. },
  587. "estore-product-grid": {
  588. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk-75x75.png",
  589. "width": 75,
  590. "height": 75
  591. },
  592. "estore-square": {
  593. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  594. "width": 230,
  595. "height": 142
  596. },
  597. "estore-slider": {
  598. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  599. "width": 230,
  600. "height": 142
  601. },
  602. "estore-medium-image": {
  603. "url": "https://btownmedia.com/wp-content/uploads/2018/10/nk.png",
  604. "width": 230,
  605. "height": 142
  606. }
  607. }
  608. }
  609.  
  610. class APIResponse {
  611. public List<Post> posts;
  612.  
  613. // add the other fields from your response if you need them
  614. }
  615.  
  616. @GET("json=get_category_posts&slug=flex-print&status=publish")
  617. Call<APIResponse> getListPost();
  618.  
  619. public static class PostAdapter implements JsonDeserializer<List<Post>> {
  620. public List<Post> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext ctx) {
  621. List<Post> vals = new ArrayList<>();
  622. if (json.has("posts") && .json.get("posts").isJsonArray()) {
  623. for (JsonElement e : json.get("posts").getAsJsonArray()) {
  624. vals.add((Post) ctx.deserialize(e, Post.class));
  625. }
  626. }
  627. return vals;
  628. }
  629. }
  630.  
  631. Type postListType = new TypeToken<List<Post>>() {}.getType();
  632.  
  633. Gson gson = new GsonBuilder()
  634. .registerTypeAdapter(postListType, new PostAdapter())
  635. .create();
  636. Retrofit retrofit = new Retrofit.Builder()
  637. .baseUrl(url1)
  638. .addConverterFactory(GsonConverterFactory.create(gson))
  639. .build();
  640.  
  641. @GET("json=get_category_posts&slug=flex-print&status=publish")
  642. Call<List<Post>> getListPost();
Add Comment
Please, Sign In to add comment