0

I have replicated this code in my Eclipse: http://alvinjayreyes.com/2012/01/02/twitter-api-on-your-java-application/ It runs but it doesn't work.

I have only this Warning "Description Resource Path Location Type Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment. Build path JRE System Library Problem"

I tried this solution: Warning - Build path specifies execution environment J2SE-1.4 with no benefits.

Does anyone have solution for this problem?

My code:

package stream;
import twitter4j.Paging;  
import twitter4j.ResponseList; 
import twitter4j.Status;
import twitter4j.Twitter;
import twitter4j.TwitterFactory;
import twitter4j.auth.AccessToken;
public class streaming {

public static void main(String[] args) {

    Twitter twitter = new TwitterFactory().getInstance();

    twitter.setOAuthConsumer("xxx","xxx");

    twitter.setOAuthAccessToken(new AccessToken("xxx","xxx"));
    try {
        ResponseList<Status> a=twitter.getUserTimeline(new Paging(1,5));
        for (Status b:a) {
            System.out.println(b.getText());
        }

    }catch(Exception e) 
            {
    e.printStackTrace();    
    }

  }

  }

Console output:

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). {"errors":[{"message":"SSL is required","code":92}]} TwitterException{exceptionCode=[ced778ef-115a04e4], statusCode=403, retryAfter=-1, rateLimitStatus=null, featureSpecificRateLimitStatus=null, version=2.2.5} at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:185) at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:65) at twitter4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java:85) at twitter4j.TwitterImpl.get(TwitterImpl.java:1895) at twitter4j.TwitterImpl.getUserTimeline(TwitterImpl.java:254) at stream.streaming.main(streaming.java:22)

Community
  • 1
  • 1
  • Can we see your code as well to verify that it is in working order. Also if you are using maven be sure to use Pascal Thivent's answer on that link (which is not the accepted answer). – hudsonb May 07 '14 at 13:47
  • Code added. I tried btpka3 answere. Where I can find the pom.xml file? – user3194349 May 07 '14 at 14:43
  • Added e.printStackTrace() to your catch block, perhaps an exception is being thrown. The fact that it runs makes me believe it is not related to the warning you are seeing. You will only have a pom.xml if your project is using maven. – hudsonb May 07 '14 at 14:53
  • e.printStackTrace() and console output added. – user3194349 May 07 '14 at 15:11
  • Try adding `-Dtwitter4j.http.useSSL=true` to your VM arguments – hudsonb May 07 '14 at 15:30

1 Answers1

0

Add -Dtwitter4j.http.useSSL=true to your VM arguments to ensure twitter4j uses SSL.

hudsonb
  • 2,214
  • 19
  • 20