0
我必須從我的Android應用程序上傳視頻到Twitter(發佈視頻鳴叫)。我使用twitter4j上傳圖片,效果很好。這是我上傳Image.I的代碼,我想將視頻從sd卡上傳到twitter。如果有人知道解決方案,請幫助我。分享視頻從SD卡到微博在Android
String status ="Check out this Tweak "+shareUrl;
try {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.setOAuthConsumerKey(consumerKey);
builder.setOAuthConsumerSecret(consumerSecret);
// Access Token
String access_token = prefs.getString(PREF_KEY_OAUTH_TOKEN, "");
// Access Token Secret
String access_token_secret = prefs.getString(PREF_KEY_OAUTH_SECRET, "");
twitter4j.auth.AccessToken token = new twitter4j.auth.AccessToken(access_token,
access_token_secret);
twitter4j.auth.AccessToken accessToken = new twitter4j.auth.AccessToken(access_token,
access_token_secret);
Twitter twitter = new TwitterFactory(builder.build()).getInstance(accessToken);
// Update status
StatusUpdate statusUpdate = new StatusUpdate(status);
InputStream is = null;
try {
is = new URL(ShowDialogforMore.twittImage).openStream();
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch(IOException e)
{
e.printStackTrace();
}
statusUpdate.setMedia("test.jpg",is);
twitter4j.Status response = twitter.updateStatus(statusUpdate);
檢查此https://stackoverflow.com/questions/20681924/upload-video-on-twitter – Ninja