我正在使用Fabric io在Android应用程序中发布推文。 这些推文正在发布,但我想检索tweetId,以便我稍后可以参考这些推文。
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();
}
});
我不知道如何或者是否可以从tweetResult对象中检索细节。
答案 0 :(得分:0)
找到了答案,只是在其他人遇到同样的问题时发布了这个答案
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);