本文整理了Java中twitter4j.Twitter.setOAuthAccessToken()
方法的一些代码示例,展示了Twitter.setOAuthAccessToken()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Twitter.setOAuthAccessToken()
方法的具体详情如下:
包路径:twitter4j.Twitter
类名称:Twitter
方法名:setOAuthAccessToken
[英]Sets the access token
[中]设置访问令牌
代码示例来源:origin: Tristan971/Lyrebird
/**
* Loads up the underlying Twitter instance with a given {@link AccessToken}. Useful for multiple account
* management.
*
* @param preloadedAccessToken The previously saved {@link AccessToken}.
*
* @see #registerAccessToken(RequestToken, String)
*/
public void registerAccessToken(final AccessToken preloadedAccessToken) {
this.accessToken = preloadedAccessToken;
this.twitter.setOAuthAccessToken(preloadedAccessToken);
}
代码示例来源:origin: org.twitter4j/twitter4j-async
@Override
public void setOAuthAccessToken(AccessToken accessToken) {
twitter.setOAuthAccessToken(accessToken);
}
代码示例来源:origin: net.homeip.yusuke/twitter4j
/**
* Sets the access token
* @param token token
* @param tokenSecret token secret
* @since Twitter 2.0.0
*/
public void setOAuthAccessToken(String token, String tokenSecret) {
setOAuthAccessToken(new AccessToken(token, tokenSecret));
}
代码示例来源:origin: stackoverflow.com
AccessToken a = new AccessToken(token, secret);
final Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(Constants.CONSUMER_KEY,
Constants.CONSUMER_SECRET);
twitter.setOAuthAccessToken(a);
代码示例来源:origin: stackoverflow.com
Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET);
twitter.setOAuthAccessToken(null);
CookieManager.getInstance().removeAllCookie();
CookieManager.getInstance().removeSessionCookie();
代码示例来源:origin: stackoverflow.com
public static void sendTweet(SharedPreferences prefs,String msg) throws Exception {
String token = prefs.getString(OAuth.OAUTH_TOKEN, "");
String secret = prefs.getString(OAuth.OAUTH_TOKEN_SECRET, "");
AccessToken a = new AccessToken(token,secret);
Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET);
twitter.setOAuthAccessToken(a);
twitter.updateStatus(msg);
}
代码示例来源:origin: stackoverflow.com
public void sendTweet(SharedPreferences prefs,String msg) throws Exception {
String token = prefs.getString(OAuth.OAUTH_TOKEN, "");
String secret = prefs.getString(OAuth.OAUTH_TOKEN_SECRET, "");
AccessToken a = new AccessToken(token,secret);
Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET);
twitter.setOAuthAccessToken(a);
twitter.updateStatus(msg);
}
代码示例来源:origin: stackoverflow.com
AccessToken a = new AccessToken(token,secret);
Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET);
twitter.setOAuthAccessToken(a);
int i=twitter.getId();
User u=twitter.showUser(i);
System.out.println("user name"+u.getName());
代码示例来源:origin: stackoverflow.com
Twitter twitter = new Twitter();
twitter.setOAuthConsumer(consumerKey,consumerSecret);
AccessToken accessToken =
twitter.getOAuthAccessToken(token, tokenSecret);
twitter.setOAuthAccessToken(accessToken);
代码示例来源:origin: stackoverflow.com
AccessToken a = new AccessToken(token,secret);
Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET);
twitter.setOAuthAccessToken(a);
//Some information is available through method calls
int myid=twitter.getId();
String username=twitter.getScreenName();
代码示例来源:origin: stackoverflow.com
TwitterFactory factory = new TwitterFactory();
Twitter twitter = factory.getInstance();
twitter.setOAuthConsumer("[consumer key]", "[consumer secret]");
AccessToken accessToken = loadAccessToken();
twitter.setOAuthAccessToken(accessToken);
代码示例来源:origin: org.tomitribe/chatterbox-twitter-impl
public void start(final BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
LOGGER.info("Starting " + this);
client = new TwitterStreamingClient(this, consumerKey, consumerSecret, accessToken, accessTokenSecret);
twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(consumerKey, consumerSecret);
twitter.setOAuthAccessToken(new AccessToken(accessToken, accessTokenSecret));
try {
client.run();
} catch (InterruptedException | ControlStreamException | IOException e) {
e.printStackTrace();
}
}
代码示例来源:origin: stackoverflow.com
AccessToken twitterToken = objectDeserialization();
Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(twitterApiKey, twitterApiSecret);
twitter.setOAuthAccessToken(new AccessToken(twitterToken.getToken(), twitterToken.getTokenSecret()));
twitter4j.Status status = twitter.updateStatus("This is sparta! :)");
代码示例来源:origin: stackoverflow.com
Twitter twitter= new TwitterFactory().getInstance();
twitter.setOAuthConsumer("************", "*************");
AccessToken newAccessToken = new AccessToken("******","*********");
System.out.println(newAccessToken);
twitter.setOAuthAccessToken(newAccessToken);
String s=twitter.getScreenName();
Status myStatus = twitter.updateStatus("Your message here");
代码示例来源:origin: stackoverflow.com
Twitter twitter = new TwitterFactory().getInstance(twitter4JConfiguration);
twitter.setOAuthConsumer(consumerKey, consumerSecret);
twitter.setOAuthAccessToken(new AccessToken(oauthToken, oauthTokenSecret));
String screenName = twitter.getScreenName(); // Returns authenticating user's screen name.
User stephenfry = twitter.showUser("stephenfry"); // Returns extended information of a given user ...
List<User> friends = twitter.getFriendsList("stephenfry", -1L); // Returns a cursored collection of user objects ...
代码示例来源:origin: jchampemont/WTFDYUM
private Twitter twitter(final Principal principal) {
final Twitter instance = twitter();
instance.setOAuthAccessToken(new AccessToken(principal.getToken(), principal.getTokenSecret()));
return instance;
}
}
代码示例来源:origin: stackoverflow.com
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
configurationBuilder
.setOAuthConsumerKey(STAConstants.TWITTER_CONSUMER_KEY);
configurationBuilder
.setOAuthConsumerSecret(STAConstants.TWITTER_CONSUMER_SECRET);
Configuration configuration = configurationBuilder.build();
TwitterFactory twitterFactory = new TwitterFactory(configuration);
Twitter twitter = twitterFactory.getInstance();
AccessToken accessToken = new AccessToken("ACCESS_TOKEN","TOKEN_SECRET");
twitter.setOAuthAccessToken(accessToken);
System.out.println(twitter.getUserTimeline("twitter"));
代码示例来源:origin: stackoverflow.com
public static void reply(long inReplyToStatusId,String text,double latitude,double longitude,TwitterFactory factory) throws TwitterException
{ AccessToken accessToken = loadAccessToken();
Twitter twitter = factory.getInstance();
twitter.setOAuthConsumer(consumerKey, consumerSecrate);
twitter.setOAuthAccessToken(accessToken);
StatusUpdate stat= new StatusUpdate(text);
stat.setInReplyToStatusId(inReplyToStatusId);
GeoLocation location= new GeoLocation(latitude, longitude);
stat.setLocation(location);
twitter.updateStatus(stat);
}'
代码示例来源:origin: stackoverflow.com
String token = prefs.getString(OAuth.OAUTH_TOKEN, "");
String secret = prefs.getString(OAuth.OAUTH_TOKEN_SECRET, "");
AccessToken a = new AccessToken(token, secret);
Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET);
twitter.setOAuthAccessToken(a);
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true).setOAuthConsumerKey(yourConsumerKey).setOAuthConsumerSecret(yourConsumerSeceret).setOAuthAccessToken(yourAccessToken).setOAuthAccessTokenSecret(yourAccessTokenSeceret);
Configuration conf = cb.build();
ImageUploadFactory factory = new ImageUploadFactory(conf);
ImageUpload upload = factory.getInstance();
String url = upload.upload(yourImage, yourCaptionWithImage); //image is a File Format and Caption is String
代码示例来源:origin: stackoverflow.com
String token = prefs.getString(OAuth.OAUTH_TOKEN, "");
String secret = prefs.getString(OAuth.OAUTH_TOKEN_SECRET, "");
AccessToken a = new AccessToken(token, secret);
Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET);
twitter.setOAuthAccessToken(a);
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true).setOAuthConsumerKey(yourConsumerKey).setOAuthConsumerSecret(yourConsumerSeceret).setOAuthAccessToken(yourAccessToken).setOAuthAccessTokenSecret(yourAccessTokenSeceret);
Configuration conf = cb.build();
ImageUploadFactory factory = new ImageUploadFactory(conf);
ImageUpload upload = factory.getInstance();
String url = upload.upload(yourImage, yourCaptionWithImage); //image is a File Format and Caption is String
内容来源于网络,如有侵权,请联系作者删除!