Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

twitter connection failed

In Android,
Twitter connection failed. SSL is required?

My code was working perfectly and it is currently a live application. However, since 2014 it hasn't been working and I've heard that Twitter has applied https or using SSL concept.

help me to solved this issue.

Here is my log.

 03-14 15:00:02.838: D/TwitterApp(697): Error getting access token
03-14 15:00:02.878: W/System.err(697): 403:The request is understood, but it has been refused. An accompanying error message will explain why. This code is used when requests are being denied due to update limits (https://support.twitter.com/articles/15364-about-twitter-limits-update-api-dm-and-following).
03-14 15:00:02.878: W/System.err(697): message - SSL is required
03-14 15:00:02.878: W/System.err(697): code - 92
03-14 15:00:02.878: W/System.err(697): Relevant discussions can be found on the Internet at:
03-14 15:00:02.878: W/System.err(697):  http://www.google.co.jp/search?q=6f0f59ca or
03-14 15:00:02.888: W/System.err(697):  http://www.google.co.jp/search?q=20d0f73f
03-14 15:00:02.888: W/System.err(697): TwitterException{exceptionCode=[6f0f59ca-20d0f73f], statusCode=403, message=SSL is required, code=92, retryAfter=-1, rateLimitStatus=RateLimitStatusJSONImpl{remaining=14, limit=15, resetTimeInSeconds=1394790328, secondsUntilReset=-18874}, version=3.0.3}
03-14 15:00:02.888: W/System.err(697):  at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:177)
03-14 15:00:02.888: W/System.err(697):  at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:61)
03-14 15:00:02.888: W/System.err(697):  at twitter4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java:89)
03-14 15:00:02.888: W/System.err(697):  at twitter4j.TwitterBaseImpl.fillInIDAndScreenName(TwitterBaseImpl.java:126)
03-14 15:00:02.888: W/System.err(697):  at twitter4j.TwitterImpl.verifyCredentials(TwitterImpl.java:592)
03-14 15:00:02.908: W/System.err(697):  at com.twitter.android.TwitterApp$3.run(TwitterApp.java:150)

twitter connection code. http://www.androidhive.info/2012/09/android-twitter-oauth-connect-tutorial/ this is a develop

like image 303
Bhavesh Jethani Avatar asked Mar 07 '14 13:03

Bhavesh Jethani


People also ask

Why is my Twitter not connecting to the internet?

Check your network connections If you're using WiFi to connect to the Twitter for Android app, try an alternate WiFi connection. If one works and the other does not, it is most likely that the WiFi connection does not accept SSL or is blocking Twitter. If you're connected to a VPN, try turning it off.

Is Twitter down today 2022?

No incidents reported today. No incidents reported.

Why is my Twitter suddenly not working?

General troubleshooting If you're having trouble with mobile.twitter.com, please try the following steps: Try clearing your cache and cookies for your device's mobile browser. You can clear cache and cookies from the settings menu for your mobile browser. Turn your phone off for 5 minutes to reset the connection.

Why do tweets fail to load?

Most of the time, this problem lies in your content preferences set to load the top tweets instead of the latest ones. However, it is also possible that Twitter's servers are offline, or your network connection is running slow. Whatever the problem is, we are here to help!


2 Answers

To my knowledge nothing much has changed with the OAuth implementation that would cause this, however, after you have authenticated using OAuth if you were then using non-SSL requests for data this may have worked previously but would not now. Twitter introduced a change restricting access to SSL/TLS connections only on January 14th 2014.

Somewhere in your Java code there will be URL's that are being used to retrieve data from Twitter's servers. I would suggest you do a search/replace through your code, where for any occurrences of http://api.twitter.com/ you replace them with https://api.twitter.com/ and this may hopefully solve this issue. It's possible there are other issues that may come to light afterwards but at least this is your first step.

By specifying https this makes sure you are using SSL protocol to ensure data is kept secure during transmission between your application and Twitter.

If you need more information to optionally validate and verify the SSL certificate in your code for additional security, then read Connecting to Twitter API via SSL on Twitter's developers documentation website.


Edit: Just to clarify further, in order to receive this error message you must have successfully authenticated using OAuth via an SSL URL, but then reverted to non-SSL URL's for follow-on data requests.

like image 94
richhallstoke Avatar answered Sep 18 '22 08:09

richhallstoke


If you're using sign-post + Twitter4j, you'd define your OAuth providers as follows:

private DefaultOAuthConsumer mOAuthConsumer = null;
private DefaultOAuthProvider httpOauthprovider = new DefaultOAuthProvider("https://api.twitter.com/oauth/request_token",
        "https://api.twitter.com/oauth/access_token",
        "https://api.twitter.com/oauth/authorize");

then perform user authentication:

private void getTwitterAuthorisation() {
    if (backend.hasNetworkConnection(this, true)) {
        new Thread(new Runnable() {
            public void run() {
                try {
                    mOAuthConsumer = newOAuthConsumer();
                    String authUrl = httpOauthprovider.retrieveRequestToken(mOAuthConsumer, CALLBACK);
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authUrl)));
                } catch (Exception e) {
                    Log.e(TAG, "getTwitterAuthorisation()", e);
                }
            }
        }).start();
    }
}

then obtain the tokens:

TwitterCredentials creds = null;
            try {
                httpOauthprovider.retrieveAccessToken(mOAuthConsumer, verifier);
                final String token = mOAuthConsumer.getToken();
                final String secret = mOAuthConsumer.getTokenSecret();
                final AccessToken accessToken = new AccessToken(token, secret);
                final Twitter twitter = TwitterFactory.getSingleton();
                twitter.setOAuthConsumer(mOAuthConsumer.getConsumerKey(), mOAuthConsumer.getConsumerSecret());
                twitter.setOAuthAccessToken(accessToken);
                final long twitterId = twitter.getId();
                final String twitterScreenName = twitter.getScreenName();
                creds = new TwitterCredentials();
                creds.oauthToken = token;
                creds.oauthSecret = secret;
                creds.twitterId = twitterId;
                creds.screenName = twitterScreenName;
            } catch (Exception e) {
                Log.e(TAG, "doTwitterConnect", e);
            }
            return creds;
like image 30
Mitch Wong Ho Avatar answered Sep 20 '22 08:09

Mitch Wong Ho