Need to retrieve the TweetId for a tweet posted so that i can refer it later

49 Views Asked by At

I am using the Fabric io for publishing the tweets in the android app. The tweets are being published but i want to retrieve the tweetId so that i can refer to these tweets later.

statusesService.update(tweetRequestObject.getString("comment"), null, null, null, null, null, null, null, new Callback<Tweet>() {
                @Override
                public void success(Result<Tweet> tweetResult) {

                    try {
                        InputStream inputStream = tweetResult.response.getBody().in();
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                        byte[] buffer = new byte[1024];
                        int length = 0;
                        while ((length = inputStream.read(buffer)) != -1) {
                            baos.write(buffer, 0, length);
                        }
                        String data = new String(baos.toByteArray(), "UTF-8");

                        Log.d(ChillumConstants.CHILLUM_CONST, "twitter Response :: " + data);

                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    //JSONObject tweetResponseObject = new JSONObject(tweetResult.response);
                    Toast toast = Toast.makeText(context, "Tweet successful", Toast.LENGTH_LONG);
                    toast.show();
                }

                @Override
                public void failure(TwitterException e) {
                    Toast toast = Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG);
                    toast.show();
                }
            });

I am not sure how or if i can retrieve the details from the tweetResult object.

1

There are 1 best solutions below

0
On

Found the answer it was always there just posting this in case someone else runs into the same issue

 long id = tweetResult.data.getId();
 String idStr = tweetResult.data.idStr;
 Log.d(ChillumConstants.CHILLUM_CONST,"Tweet id : "+id);
 Log.d(ChillumConstants.CHILLUM_CONST,"Tweet id Str : "+idStr);