本文整理匯總了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();
}