/** * To upload a picture with some piece of text. * * * @param file The file which we want to share with our tweet * @param message Message to display with picture * @param twitter Instance of authorized Twitter class * @throws Exception exception if any */ public void uploadPic(File file, String message,Twitter twitter) throws Exception { try{ StatusUpdate status = new StatusUpdate(message); status.setMedia(file); twitter.updateStatus(status);} catch(TwitterException e){ Log.d("TAG", "Pic Upload error" + e.getErrorMessage()); throw e; } }
public void uploadPic(File file, String message) throws Exception { try{ StatusUpdate status = new StatusUpdate(message); status.setMedia(file); mTwitter.updateStatus(status);} catch(TwitterException e){ Log.d("TAG", "Pic Upload error" + e.getErrorMessage()); throw e; } }
/** * To upload a picture with some piece of text. * * * @param file The file which we want to share with our tweet * @param message Message to display with picture * @param twitter Instance of authorized Twitter class * @throws Exception exception if any */ public void uploadPic(File file, String message,Twitter twitter) throws Exception { try{ StatusUpdate status = new StatusUpdate(message); status.setMedia(file); twitter.updateStatus(status);} catch(TwitterException e){ Log.d("TAG", "Pic Upload error" + e.getErrorMessage()); throw e; } }
/** * @param name media name * @param body media body * @return this instance * @since Twitter4J 2.2.5 */ public StatusUpdate media(String name, InputStream body) { setMedia(name, body); return this; }
/** * @param file media file * @return this instance * @since Twitter4J 2.2.5 */ public StatusUpdate media(File file) { setMedia(file); return this; }
// the txt message StatusUpdate status = new StatusUpdate(Msg); // set the image file as media with the message. status.setMedia(imgFile);
StatusUpdate status = new StatusUpdate(message); status.setMedia(file); // image location twitter.updateStatus(status);
StatusUpdate status = new StatusUpdate(String status); File file = new File(imageFilePath); status.setMedia(file); mTwitter.updateStatus(status);
StatusUpdate statusUpdate = new StatusUpdate("Hello Twitter"); String imageUrl = "http://example.com/image.png"; URL url = new URL(imageUrl); URLConnection urlConnection = url.openConnection(); InputStream in = new BufferedInputStream(urlConnection.getInputStream()); statusUpdate.setMedia("image.png", in); twitter4j.Status status = twitter.updateStatus(statusUpdate); //might be a good idea to close the inputstream in a finally block
public void tweet(File f, String Message) throws TwitterException { StatusUpdate status = new StatusUpdate(Message); status.setMedia(f); // twitter is an object of Twitter for which you have set the authentication token twitter.updateStatus(status); }
public void tweetPicture(File file, String message) throws Exception { try{ StatusUpdate status = new StatusUpdate(message); status.setMedia(file); mTwitter.updateStatus(status);} catch(TwitterException e){ Log.d("TAG", "Pic Uploading error" + e.getErrorMessage()); throw e; } }
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 twitter = new TwitterFactory(conf).getInstance(); Bitmap bmp = BitmapFactory.decodeResource( TwitterFriends.this.getResources(), R.drawable.edit_ic); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.PNG, 100, stream); byte[] byteArray = stream.toByteArray(); ByteArrayInputStream bis = new ByteArrayInputStream(byteArray); StatusUpdate status = new StatusUpdate(message); status.setMedia("newyear", bis); try { twitter.updateStatus(status); } catch (Exception e) { e.printStackTrace(); }
final StatusUpdate statusUpdate = new StatusUpdate("Hallee hallo my status java.lang.String here..."); // now do as you did until: ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.PNG, 100, baos); imageBytes = baos.toByteArray(); encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT); // then flip the stream byte[] myTwitterUploadBytes = bos.toByteArray(); ByteArrayInputStream bis = new ByteArrayInputStream(myTwitterUploadBytes); // doo and double check your encoding etc, similar to in your question.. statusUpdate.setMedia("give me a java.lang.String name", bis); // then continue just using twitter for j- update status as you would //... get twitter etc... // twitter4j.Status response = twitter.updateStatus(statusUpdate);
public void Share_Pic_Text_Titter(File image_path, String message, Twitter twitter) throws Exception { try { StatusUpdate st = new StatusUpdate(message); st.setMedia(image_path); twitter.updateStatus(st); } catch (TwitterException e) { Log.d("Error==>", "Pic Upload error" + e.getErrorMessage()); throw e; } }
** * To upload a picture with some piece of text. * * * @param file The file which we want to share with our tweet * @param message Message to display with picture * @param twitter Instance of authorized Twitter class * @throws Exception exception if any */ public void uploadPic(File file, String message,Twitter twitter) throws Exception { try{ StatusUpdate status = new StatusUpdate(message); status.setMedia(file); twitter.updateStatus(status);} catch(TwitterException e){ Log.d("TAG", "Pic Upload error" + e.getErrorMessage()); throw e; } }
ConfigurationBuilder twitterConfigBuilder = new ConfigurationBuilder(); twitterConfigBuilder.setDebugEnabled(true); twitterConfigBuilder.setOAuthConsumerKey("consumerkey"); twitterConfigBuilder.setOAuthConsumerSecret("consumersecret"); twitterConfigBuilder.setOAuthAccessToken("accesstoken"); twitterConfigBuilder.setOAuthAccessTokenSecret("accesstokensecret"); Twitter twitter = new TwitterFactory(twitterConfigBuilder.build()).getInstance(); String statusMessage = "Watch out this interesting offer I came across today"; File file = new File("/images/Done.jpg"); StatusUpdate status = new StatusUpdate(message); status.setMedia(file); // set the image to be uploaded here. twitter.updateStatus(status);
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.setOAuthConsumerKey(context.getResources().getString(R.string.twitter_consumer_key)); configurationBuilder.setOAuthConsumerSecret(context.getResources().getString(R.string.twitter_consumer_secret)); configurationBuilder.setOAuthAccessToken(LoginActivity.getAccessToken((context))); configurationBuilder.setOAuthAccessTokenSecret(LoginActivity.getAccessTokenSecret(context)); Configuration configuration = configurationBuilder.build(); Twitter twitter = new TwitterFactory(configuration).getInstance(); StatusUpdate status = new StatusUpdate(message); status.setMedia(file); // set the image to be uploaded here. twitter.updateStatus(status);
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.setOAuthConsumerKey(context.getResources().getString(R.string.twitter_consumer_key)); configurationBuilder.setOAuthConsumerSecret(context.getResources().getString(R.string.twitter_consumer_secret)); configurationBuilder.setOAuthAccessToken(LoginActivity.getAccessToken((context))); configurationBuilder.setOAuthAccessTokenSecret(LoginActivity.getAccessTokenSecret(context)); Configuration configuration = configurationBuilder.build(); Twitter twitter = new TwitterFactory(configuration).getInstance(); StatusUpdate status = new StatusUpdate(message); status.setMedia(file); // set the image to be uploaded here. twitter.updateStatus(status);
String accesst = "ACCESS_TOKEN"; String accessts = "TOKEN_SECRET"; ConfigurationBuilder builder = new ConfigurationBuilder(); builder.setOAuthAccessToken(accesst); builder.setOAuthAccessTokenSecret(accessts); builder.setOAuthConsumerKey("CLIENT_ID"); builder.setOAuthConsumerSecret("CLIENT_SECRET"); OAuthAuthorization auth = new OAuthAuthorization(builder.build()); Twitter twitter_auth = new TwitterFactory().getInstance(auth); String screenName = twitter_auth.getScreenName(); StatusUpdate status = new StatusUpdate("STATUS_TEXT"); status.setMedia(new File("YOUR_FILE_PATH"));// BY SPECIFYING FILE PATH //status.setMedia("File name", new FileInputStream("")); // By InputStream Status updateStatus = twitter_auth.updateStatus(status); long id = updateStatus.getId(); // id of the status posted