Search code examples
androidtwitter4j

twitter4j get the tweeted id


am using twitter4j for my app. am able to post media/text using twitter4j. but i want the id of my status.

The method getId() is undefined for the type StatusUpdate

i have tired using

StatusUpdate status = new StatusUpdate(mfinalmsg);

            if (imgdata != null) {
                ByteArrayInputStream bis = new ByteArrayInputStream(imgdata);

                status.setMedia("pic", bis);

            }

            twitter.updateStatus(status);
             long statusId = (int)status.getId();

so i have replaced StatusUpdate with status. but how can i upload media/urllink.

 twitter4j.Status status = twitter.updateStatus(mfinalmsg);
             long statusId = (int)status.getId();

i am ready to use twitter rest api. but i dont know how to send params . please guide me ..


Solution

  • StatusUpdate statusUpdate = new StatusUpdate(mfinalmsg);
    
    if (imgdata != null) {
        ByteArrayInputStream bis = new ByteArrayInputStream(imgdata);    
        statusUpdate.setMedia("pic", bis);   
    }
    
    Status status  = twitter.updateStatus(statusUpdate);
    long statusId = (int)status.getId();
    

    twitter.updateStatus() method returns Status object. Use that object to get id, not the object of StatusUpdate class.