简体   繁体   中英

Java Eclipse Warning using twitter4j

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)

-Dtwitter4j.http.useSSL=true添加到您的VM参数中,以确保twitter4j使用SSL。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM