Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- request = GraphRequest.newGraphPathRequest(
- accessToken, "/" + conversation_id,
- new GraphRequest.Callback() {
- @Override
- public void onCompleted(GraphResponse response) {
- // Insert your code here
- Log.e("Response", response + "");
- JSONObject jsonObject = response.getJSONObject();
- if (jsonObject != null) {
- String conversation_id = jsonObject.optString("id");
- JSONObject conversation_object = jsonObject.optJSONObject("messages");
- next = conversation_object.optJSONObject("paging").optString("next");
- previous = conversation_object.optJSONObject("paging").optString("previous");
- JSONArray data = conversation_object.optJSONArray("data");
- if (data != null) {
- for (int i = 0; i < data.length(); i++) {
- JSONObject object = data.optJSONObject(i);
- String message = object.optString("message");
- String created_time = object.optString("created_time");
- String message_id = object.optString("id");
- JSONObject from = object.optJSONObject("from");
- String from_name = from.optString("name");
- String from_id = from.optString("id");
- Model model = new Model();
- model.setConversation_id(conversation_id);
- model.setMessage(message);
- model.setMessage_id(message_id);
- model.setFrom_id(from_id);
- model.setFrom_name(from_name);
- model.setCreated_time(created_time);
- if (from_id.equals(page_id)) {
- model.setIs_page(true);
- } else {
- model.setIs_page(false);
- }
- arrayList.add(model);
- }
- adapter = new Page_Conversation_Send_Adpter(Page_Send_Conversation.this, arrayList);
- recyclerView.setAdapter(adapter);
- adapter.notifyDataSetChanged();
- recyclerView.scrollToPosition(arrayList.size());
- }
- }
- }
- });
- Bundle parameters = new Bundle();
- parameters.putString("fields", "messages{from,message,created_time}");
- request.setParameters(parameters);
- request.executeAsync();
- {
- "id":"t_mid.1451223349751:29a5b9f29647937598",
- "messages":{
- "data":[
- {
- "from":{
- "name":"EverGreen Associates",
- "email":"554432738045284@facebook.com",
- "id":"554432738045284"
- },
- "message":"hello i am sending message from application",
- "created_time":"2015-12-29T09:03:34+0000",
- "id":"m_mid.1451379814598:e7134068a264fd4061"
- },
- {
- "from":{
- "name":"Pankaj Arora",
- "email":"10205905497613544@facebook.com",
- "id":"10205905497613544"
- },
- "message":"Yes i got your message",
- "created_time":"2015-12-27T17:09:37+0000",
- "id":"m_mid.1451236177136:13c782b85a1e0ef312"
- },
- {
- "from":{
- "name":"EverGreen Associates",
- "email":"554432738045284@facebook.com",
- "id":"554432738045284"
- },
- "message":"Testing from Application if you get please reply",
- "created_time":"2015-12-27T17:09:06+0000",
- "id":"m_mid.1451236146909:8c0c770d19dbd76a97"
- },
- {
- "from":{
- "name":"EverGreen Associates",
- "email":"554432738045284@facebook.com",
- "id":"554432738045284"
- },
- "message":"",
- "created_time":"2015-12-27T17:01:24+0000",
- "id":"m_mid.1451235684417:5f005334e5fc36c269"
- },
- {
- "from":{
- "name":"EverGreen Associates",
- "email":"554432738045284@facebook.com",
- "id":"554432738045284"
- },
- "message":"",
- "created_time":"2015-12-27T17:01:23+0000",
- "id":"m_mid.1451235683641:135bce3776d3b93940"
- },
- {
- "from":{
- "name":"EverGreen Associates",
- "email":"554432738045284@facebook.com",
- "id":"554432738045284"
- },
- "message":"",
- "created_time":"2015-12-27T16:54:31+0000",
- "id":"m_mid.1451235270927:3f21e6ca31f3bca052"
- },
- {
- "from":{
- "name":"EverGreen Associates",
- "email":"554432738045284@facebook.com",
- "id":"554432738045284"
- },
- "message":"",
- "created_time":"2015-12-27T16:34:43+0000",
- "id":"m_mid.1451234082533:2696495c7b104d6a38"
- },
- {
- "from":{
- "name":"Pankaj Arora",
- "email":"10205905497613544@facebook.com",
- "id":"10205905497613544"
- },
- "message":"got it",
- "created_time":"2015-12-27T13:37:05+0000",
- "id":"m_mid.1451223425939:3a960e07faa0d78732"
- },
- {
- "from":{
- "name":"EverGreen Associates",
- "email":"554432738045284@facebook.com",
- "id":"554432738045284"
- },
- "message":"hello",
- "created_time":"2015-12-27T13:36:29+0000",
- "id":"m_mid.1451223389308:0d7549545b87297930"
- },
- {
- "from":{
- "name":"Pankaj Arora",
- "email":"10205905497613544@facebook.com",
- "id":"10205905497613544"
- },
- "message":"Hello Dhaval Sir, how the things",
- "created_time":"2015-12-27T13:35:50+0000",
- "id":"m_mid.1451223349751:29a5b9f29647937598"
- }
- ],
- "paging":{
- "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",
- "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"
- }
- }
- }
Add Comment
Please, Sign In to add comment