问题
I want to post image to twitter on my app. I use "twitter4j" library to post only text. But i cannot find how to post image with text. Thanks for help.
回答1:
- To post a image you have to use media extension of Twitter4j and register your app with either TwitPic or YFrog .
Get KEY and TOKEN from those services and then
/* * Upload File to twitPic and get url . Then append this url to your twitter message. */ public static String upload_twic_pic(File file) throws TwitterException { String url = null; if (file != null) { Configuration conf = new ConfigurationBuilder().setMediaProviderAPIKey(TWITPIC_KEY).build(); ImageUpload upload = new ImageUploadFactory(conf).getInstance(MediaProvider.PLIXI); //Use ImageUploadFactory url = upload.upload(file); } return url;
回答2:
Here is a link to a one file solution that explains exactly how to integrate picture/text tweets into an android app.
回答3:
You can use socialauth android library
Find SocialAuth Android Here
来源:https://stackoverflow.com/questions/9693586/how-to-post-picture-to-twitter-using-twitter4j-library-in-android