Shvet

Untitled

Dec 29th, 2015
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.16 KB | None | 0 0
  1. request = GraphRequest.newGraphPathRequest(
  2. accessToken, "/" + conversation_id,
  3. new GraphRequest.Callback() {
  4. @Override
  5. public void onCompleted(GraphResponse response) {
  6. // Insert your code here
  7. Log.e("Response", response + "");
  8. JSONObject jsonObject = response.getJSONObject();
  9. if (jsonObject != null) {
  10.  
  11. String conversation_id = jsonObject.optString("id");
  12. JSONObject conversation_object = jsonObject.optJSONObject("messages");
  13.  
  14. next = conversation_object.optJSONObject("paging").optString("next");
  15. previous = conversation_object.optJSONObject("paging").optString("previous");
  16.  
  17. JSONArray data = conversation_object.optJSONArray("data");
  18. if (data != null) {
  19.  
  20. for (int i = 0; i < data.length(); i++) {
  21.  
  22. JSONObject object = data.optJSONObject(i);
  23. String message = object.optString("message");
  24. String created_time = object.optString("created_time");
  25. String message_id = object.optString("id");
  26. JSONObject from = object.optJSONObject("from");
  27. String from_name = from.optString("name");
  28. String from_id = from.optString("id");
  29.  
  30. Model model = new Model();
  31. model.setConversation_id(conversation_id);
  32. model.setMessage(message);
  33. model.setMessage_id(message_id);
  34. model.setFrom_id(from_id);
  35. model.setFrom_name(from_name);
  36. model.setCreated_time(created_time);
  37. if (from_id.equals(page_id)) {
  38. model.setIs_page(true);
  39. } else {
  40. model.setIs_page(false);
  41. }
  42. arrayList.add(model);
  43. }
  44. adapter = new Page_Conversation_Send_Adpter(Page_Send_Conversation.this, arrayList);
  45. recyclerView.setAdapter(adapter);
  46. adapter.notifyDataSetChanged();
  47. recyclerView.scrollToPosition(arrayList.size());
  48. }
  49. }
  50. }
  51. });
  52.  
  53. Bundle parameters = new Bundle();
  54. parameters.putString("fields", "messages{from,message,created_time}");
  55. request.setParameters(parameters);
  56. request.executeAsync();
  57.  
  58.  
  59. {
  60. "id":"t_mid.1451223349751:29a5b9f29647937598",
  61. "messages":{
  62. "data":[
  63. {
  64. "from":{
  65. "name":"EverGreen Associates",
  66. "email":"554432738045284@facebook.com",
  67. "id":"554432738045284"
  68. },
  69. "message":"hello i am sending message from application",
  70. "created_time":"2015-12-29T09:03:34+0000",
  71. "id":"m_mid.1451379814598:e7134068a264fd4061"
  72. },
  73. {
  74. "from":{
  75. "name":"Pankaj Arora",
  76. "email":"10205905497613544@facebook.com",
  77. "id":"10205905497613544"
  78. },
  79. "message":"Yes i got your message",
  80. "created_time":"2015-12-27T17:09:37+0000",
  81. "id":"m_mid.1451236177136:13c782b85a1e0ef312"
  82. },
  83. {
  84. "from":{
  85. "name":"EverGreen Associates",
  86. "email":"554432738045284@facebook.com",
  87. "id":"554432738045284"
  88. },
  89. "message":"Testing from Application if you get please reply",
  90. "created_time":"2015-12-27T17:09:06+0000",
  91. "id":"m_mid.1451236146909:8c0c770d19dbd76a97"
  92. },
  93. {
  94. "from":{
  95. "name":"EverGreen Associates",
  96. "email":"554432738045284@facebook.com",
  97. "id":"554432738045284"
  98. },
  99. "message":"",
  100. "created_time":"2015-12-27T17:01:24+0000",
  101. "id":"m_mid.1451235684417:5f005334e5fc36c269"
  102. },
  103. {
  104. "from":{
  105. "name":"EverGreen Associates",
  106. "email":"554432738045284@facebook.com",
  107. "id":"554432738045284"
  108. },
  109. "message":"",
  110. "created_time":"2015-12-27T17:01:23+0000",
  111. "id":"m_mid.1451235683641:135bce3776d3b93940"
  112. },
  113. {
  114. "from":{
  115. "name":"EverGreen Associates",
  116. "email":"554432738045284@facebook.com",
  117. "id":"554432738045284"
  118. },
  119. "message":"",
  120. "created_time":"2015-12-27T16:54:31+0000",
  121. "id":"m_mid.1451235270927:3f21e6ca31f3bca052"
  122. },
  123. {
  124. "from":{
  125. "name":"EverGreen Associates",
  126. "email":"554432738045284@facebook.com",
  127. "id":"554432738045284"
  128. },
  129. "message":"",
  130. "created_time":"2015-12-27T16:34:43+0000",
  131. "id":"m_mid.1451234082533:2696495c7b104d6a38"
  132. },
  133. {
  134. "from":{
  135. "name":"Pankaj Arora",
  136. "email":"10205905497613544@facebook.com",
  137. "id":"10205905497613544"
  138. },
  139. "message":"got it",
  140. "created_time":"2015-12-27T13:37:05+0000",
  141. "id":"m_mid.1451223425939:3a960e07faa0d78732"
  142. },
  143. {
  144. "from":{
  145. "name":"EverGreen Associates",
  146. "email":"554432738045284@facebook.com",
  147. "id":"554432738045284"
  148. },
  149. "message":"hello",
  150. "created_time":"2015-12-27T13:36:29+0000",
  151. "id":"m_mid.1451223389308:0d7549545b87297930"
  152. },
  153. {
  154. "from":{
  155. "name":"Pankaj Arora",
  156. "email":"10205905497613544@facebook.com",
  157. "id":"10205905497613544"
  158. },
  159. "message":"Hello Dhaval Sir, how the things",
  160. "created_time":"2015-12-27T13:35:50+0000",
  161. "id":"m_mid.1451223349751:29a5b9f29647937598"
  162. }
  163. ],
  164. "paging":{
  165. "previous":"https:\/\/graph.facebook.com\/v2.5\/t_mid.1451223349751:29a5b9f29647937598\/messages?fields=from,message,created_time&access_token=CAAGTZCek8UwkBAEYmOqBLADRDijTXNUKbZCylJJqRe8QibvkXjyG1aOyKkl1MV2kpb7piFjqmbE1s1QloSvvCpO50tnP7Fj6F7qqrq12uYVZCqv9r9Ovd6PiMFYIrGvxk5Qxwcd2v26JSFaP56l8UQnYBwo7F7dbWVINbhBfstiqW02JSew&limit=25&since=1451379814&__paging_token=enc_AdBtr7gORiR2C0qzqZBjo8lGMQnSMS36H3ZA2rHbJJfLS3Yey3jyMK1ZCmTpd5RJp5lZAV32HAQVNsGlcuCEqB9UceSLZBcgHkfYnNXZA9ixdVfAFkNAZDZD&__previous=1",
  166. "next":"https:\/\/graph.facebook.com\/v2.5\/t_mid.1451223349751:29a5b9f29647937598\/messages?fields=from,message,created_time&access_token=CAAGTZCek8UwkBAEYmOqBLADRDijTXNUKbZCylJJqRe8QibvkXjyG1aOyKkl1MV2kpb7piFjqmbE1s1QloSvvCpO50tnP7Fj6F7qqrq12uYVZCqv9r9Ovd6PiMFYIrGvxk5Qxwcd2v26JSFaP56l8UQnYBwo7F7dbWVINbhBfstiqW02JSew&limit=25&until=1451223350&__paging_token=enc_AdBOHirUzZAZAYhtAz5d3VYFbmj3DEmyJduck44Ry2NynhLoMheFZBHu77uKZAEbzvtLKcg6aAVBWnvssFIqUwdTfaPnrrOY0XLTigX5Y2RSCX3wqAZDZD"
  167. }
  168. }
  169. }
Add Comment
Please, Sign In to add comment