In my app I need to share link for promo site via Facebook and twitter, in facebook we got something like "share dialog" or post bundle like
Request request = new Request(Session.getActiveSession(), "me/feed", bundle, HttpMethod.POST,
new Request.Callback(){
@Override
public void onCompleted(Response response) {
...
}
});
but there are no twitter sdk for android(trully I use twitter4j) and no way to post bundle
so how to tweet link via twitter?
Look at the Web address in your browser's address bar. This is your Twitter URL. Copy the link and share it with friends to lead them directly to your Twitter profile.
Go to Settings > Apps > Twitter > under Defaults go to Set as default and turn off Open supported links.
If you send text with link like "Here is our link: http://stackoverflow.com" - twitter will understand it and get info from your link and show it - as I understand you need to see your recognized link in twitter feed. To post link you can make intent like @Adrian Sicaru or create your own custom dialog using asynctask with twitter4j as you mention:
@Override
protected Bundle doInBackground(Bundle... params) {
Bundle args = params[0];
Bundle result = new Bundle();
String paramMessage = args.getString(MESSAGE);
String paramLink = args.getString(LINK);
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.setOAuthConsumerKey("your ConsumerKey");
builder.setOAuthConsumerSecret("your ConsumerSecret");
String accessToken = "your Token";
String accessTokenSecret = "your Secret";
TwitterFactory factory = new TwitterFactory(builder.build());
mTwitter = factory.getInstance(new AccessToken(accessToken, accessTokenSecret));
try {
StatusUpdate status = new StatusUpdate(paramMessage);
if (paramLink != null) {
status = new StatusUpdate(paramMessage + " " + paramLink);
}
mTwitter.updateStatus(status);
} catch (TwitterException e) {
result.putString(RESULT_ERROR, e.getMessage());
}
return result;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With