当前位置: 首页>>代码示例>>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;未经允许,请勿转载。