當前位置: 首頁>>代碼示例>>Java>>正文


Java RequestToken.getAuthorizationURL方法代碼示例

本文整理匯總了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;
}
 
開發者ID:mthli,項目名稱:Tweetin,代碼行數:24,代碼來源:GetAuthorizationURLTask.java

示例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();
}
 
開發者ID:BloodShura,項目名稱:MPSBot,代碼行數:33,代碼來源:ConnectedBot.java

示例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);
    }
}
 
開發者ID:SerCeMan,項目名稱:twiktor,代碼行數:11,代碼來源:Authorizator.java

示例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();
}
 
開發者ID:s-aska,項目名稱:Justaway-for-Android-Original,代碼行數:37,代碼來源:SignInActivity.java


注:本文中的twitter4j.auth.RequestToken.getAuthorizationURL方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。