本文整理汇总了Java中twitter4j.auth.RequestToken.getAuthorizationURL方法的典型用法代码示例。如果您正苦于以下问题:Java RequestToken.getAuthorizationURL方法的具体用法?Java RequestToken.getAuthorizationURL怎么用?Java RequestToken.getAuthorizationURL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twitter4j.auth.RequestToken
的用法示例。
在下文中一共展示了RequestToken.getAuthorizationURL方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doInBackground
import twitter4j.auth.RequestToken; //导入方法依赖的package包/类
@Override
protected Boolean doInBackground(Void... params) {
String consumerKey = splashActivity.getString(R.string.app_consumer_key);
String consumerSecret = splashActivity.getString(R.string.app_consumer_secret);
Twitter twitter = TwitterUnit.getTwitterFromInstance();
twitter.setOAuthConsumer(consumerKey, consumerSecret);
try {
RequestToken requestToken = twitter.getOAuthRequestToken(splashActivity.getString(R.string.app_callback_url));
token = requestToken.getToken();
tokenSecret = requestToken.getTokenSecret();
authorizationURL = requestToken.getAuthorizationURL();
} catch (Exception e) {
return false;
}
if (isCancelled()) {
return false;
}
return true;
}
示例2: prepare
import twitter4j.auth.RequestToken; //导入方法依赖的package包/类
public void prepare(Function<URL, String> pinEvaluator) throws IllegalStateException, MalformedURLException, TwitterException {
ApiKeys keys = getBot().getApiKeys();
if (!isPrepared()) {
Twitter handler = TwitterFactory.getSingleton();
handler.setOAuthConsumer(keys.getConsumerKey(), keys.getConsumerSecret());
RequestToken requestToken = handler.getOAuthRequestToken();
URL url = new URL(requestToken.getAuthorizationURL());
while (accessToken == null) {
String pin = pinEvaluator.apply(url);
try {
if (pin != null && !pin.isEmpty()) {
this.accessToken = handler.getOAuthAccessToken(requestToken, pin);
this.handler = handler;
}
else {
return;
}
}
catch (TwitterException exception) {
System.err.println("Could not evaluate OAuth access token:");
System.err.println(exception);
}
}
}
getHandler().verifyCredentials();
}
示例3: beginAuth
import twitter4j.auth.RequestToken; //导入方法依赖的package包/类
public String beginAuth(String login) {
try {
Twitter twitter = createTwitter();
RequestToken requestToken = twitter.getOAuthRequestToken(getCallbackURL(login));
requests.put(login, requestToken);
return requestToken.getAuthorizationURL();
} catch (TwitterException e) {
throw new RuntimeException("Imposible to begin auth of " + login, e);
}
}
示例4: startOAuth
import twitter4j.auth.RequestToken; //导入方法依赖的package包/类
@OnClick(R.id.start_oauth_button)
void startOAuth() {
MessageUtil.showProgressDialog(this, getString(R.string.progress_process));
AsyncTask<Void, Void, RequestToken> task = new AsyncTask<Void, Void, RequestToken>() {
@Override
protected RequestToken doInBackground(Void... params) {
try {
Twitter twitter = TwitterManager.getTwitterInstance();
return twitter.getOAuthRequestToken(getString(R.string.twitter_callback_url));
} catch (TwitterException e) {
e.printStackTrace();
return null;
}
}
@Override
protected void onPostExecute(RequestToken token) {
MessageUtil.dismissProgressDialog();
if (token == null) {
MessageUtil.showToast(R.string.toast_connection_failure);
return;
}
final String url = token.getAuthorizationURL();
if (url == null) {
MessageUtil.showToast(R.string.toast_get_authorization_url_failure);
return;
}
mRequestToken = token;
mStartOauthButton.setVisibility(View.GONE);
mConnectWithTwitter.setVisibility(View.GONE);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
}
};
task.execute();
}