本文整理汇总了Java中twitter4j.auth.OAuthAuthorization.setOAuthConsumer方法的典型用法代码示例。如果您正苦于以下问题:Java OAuthAuthorization.setOAuthConsumer方法的具体用法?Java OAuthAuthorization.setOAuthConsumer怎么用?Java OAuthAuthorization.setOAuthConsumer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twitter4j.auth.OAuthAuthorization
的用法示例。
在下文中一共展示了OAuthAuthorization.setOAuthConsumer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setOAuthConsumer
import twitter4j.auth.OAuthAuthorization; //导入方法依赖的package包/类
@Override
public synchronized void setOAuthConsumer(String consumerKey, String consumerSecret) {
if (null == consumerKey) {
throw new NullPointerException("consumer key is null");
}
if (null == consumerSecret) {
throw new NullPointerException("consumer secret is null");
}
if (auth instanceof NullAuthorization) {
if (conf.isApplicationOnlyAuthEnabled()) {
OAuth2Authorization oauth2 = new OAuth2Authorization(conf);
oauth2.setOAuthConsumer(consumerKey, consumerSecret);
auth = oauth2;
} else {
OAuthAuthorization oauth = new OAuthAuthorization(conf);
oauth.setOAuthConsumer(consumerKey, consumerSecret);
auth = oauth;
}
} else if (auth instanceof BasicAuthorization) {
XAuthAuthorization xauth = new XAuthAuthorization((BasicAuthorization) auth);
xauth.setOAuthConsumer(consumerKey, consumerSecret);
auth = xauth;
} else if (auth instanceof OAuthAuthorization || auth instanceof OAuth2Authorization) {
throw new IllegalStateException("consumer key/secret pair already set.");
}
}
示例2: getInstance
import twitter4j.auth.OAuthAuthorization; //导入方法依赖的package包/类
/**
* Returns a OAuth Authenticated instance.<br>
* consumer key and consumer Secret must be provided by twitter4j.properties, or system properties.<br>
* Unlike {@link AsyncTwitter#setOAuthAccessToken(twitter4j.auth.AccessToken)}, this factory method potentially returns a cached instance.
*
* @param accessToken access token
* @return an instance
*/
public AsyncTwitter getInstance(AccessToken accessToken) {
String consumerKey = conf.getOAuthConsumerKey();
String consumerSecret = conf.getOAuthConsumerSecret();
if (null == consumerKey && null == consumerSecret) {
throw new IllegalStateException("Consumer key and Consumer secret not supplied.");
}
OAuthAuthorization oauth = new OAuthAuthorization(conf);
oauth.setOAuthConsumer(consumerKey, consumerSecret);
oauth.setOAuthAccessToken(accessToken);
return new AsyncTwitterImpl(conf, oauth);
}
示例3: getOAuthOuthorization
import twitter4j.auth.OAuthAuthorization; //导入方法依赖的package包/类
private OAuthAuthorization getOAuthOuthorization(Configuration conf) {
OAuthAuthorization oauth = new OAuthAuthorization(conf);
oauth.setOAuthConsumer(desktopConsumerKey, desktopConsumerSecret);
oauth.setOAuthAccessToken(new AccessToken(id1.accessToken, id1.accessTokenSecret));
return oauth;
}