"需要使用SSL"除了在使用Twitter4J库请求OAuthRequest令牌 [英] "SSL is required" exception while requesting OAuthRequest Token using Twitter4J library

查看:143
本文介绍了"需要使用SSL"除了在使用Twitter4J库请求OAuthRequest令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是想提供这里此示例应用程序,我得到是必需的SSL 异常在这个特殊的一块code的

I was trying this sample application provided here, I am getting "SSL is required" exception in this particular piece of code

private void askOAuth() {
        ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
        configurationBuilder.setOAuthConsumerKey(Const.CONSUMER_KEY);
        configurationBuilder.setOAuthConsumerSecret(Const.CONSUMER_SECRET);
        Configuration configuration = configurationBuilder.build();
        twitter = new TwitterFactory(configuration).getInstance();

        try {
            requestToken = twitter.getOAuthRequestToken(Const.CALLBACK_URL);
            Toast.makeText(this, "Please authorize this app!", Toast.LENGTH_LONG).show();
            this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(requestToken.getAuthenticationURL())));
        } catch (TwitterException e) {
            Log.e(TAG, e.getMessage());
        }
    }

twitter.getOAuthRequestToken(Const.CALLBACK_URL); 执行我得到这个例外

我配置的消费重点,消费秘密回调URL到我的应用程序。

I have configure consumer key, consumer secret and callback url to that of my application.

推荐答案

得到这个解决
如果你正在使用twitter4j版本3或更低,在ConfigurationBuilder你必须设置

Got this solved If you are using twitter4j version 3 or less that in ConfigurationBuilder you have to set

configurationBuilder.setUseSSL(true);

因为Twitter已经取得SSL强制性使API请求

because twitter has made ssl as mandatory to make API request

有关twitter4j 4版,默认情况下使用SSL。

for twitter4j version 4, by default ssl is used.

这篇关于"需要使用SSL"除了在使用Twitter4J库请求OAuthRequest令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆