Posting Image on twitter using android app

android

#1

How to upload server image on twitter through android app using fabric api.


#2

I wants to upload my server image, by using url that is pointing to my server image like - http://www.demo.com/pictures/xyz.png

I try to use :slight_smile:

Uri uri=Uri.parse(url);

TweetComposer.Builder builder = new TweetComposer.Builder(ComplainActivity.this)
                        .text("textToShare")
                        .image(uri);

builder.show();

but only text is post on twitter but not image.


#3

Hey @sushil_dhamal,

TwitterKit will help you do that.

If your users have Twitter App installed in their Android phones, you can use Android intents to open Twitter app to compose a tweet and supply the URI of the image.
You’ll have to have this image locally available, to supply to the composers.

Alternatively, you can also use the TwitterKit TweetComposer to present an in-app Tweet Composer with images attached, so that the user can tweet without going outside of your app.

Make sure the user is logged in before using TweetComposer.
Logging the user in will also be facilitated by TwitterKit.

This documentation details about how to compose a tweet with above two methods : https://docs.fabric.io/android/twitter/compose-tweets.html

And this documentation explains how to have users log in with Twitter : https://docs.fabric.io/android/twitter/authentication.html

All the best!


Play video android?
#4

hey @AmanAlam,

Thanks for your response. The issue is I have developed an APP through which a user can share his post either on Facebook or Twitter. In some cases the user might have a PIC associated to the content.

In that case both the content and pic should be shared on twitter. Please note that image we are storing at server which needs to be posted.


#5

Hey @sushil_dhamal ,

If you want to upload the image as a native media to the tweet, you’ll have to have the image in local storage and supply it’s URI.
You may want to download and save your image from the server URL, before doing this.

If you’d choose to rather put a url to the image to the tweet, you can put the URL in the tweet body, but in this case the image will not be attached with the tweet as a native media.


#6

Hey, @AmanAlam,

Thanks for giving me a valueable response.