I'm trying my first ever code project with Twitter4J (just for fun), in which it should show the five most recent tweets of my user timeline. I found this code online and have updated it with my personal data, but it keeps throwing this exception:
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}]} Relevant discussions can be on the Internet at: http://www.google.co.jp/search?q=e5488403 TwitterException{exceptionCode=[e5488403-0cac370f], statusCode=403, retryAfter=-1, rateLimitStatus=null, featureSpecificRateLimitStatus=null, version=2.2.5}
Any ideas on why it isn't working? I'm still very new to this and would love advice.
import twitter4j.Paging;
import twitter4j.ResponseList;
import twitter4j.Status;
import twitter4j.Twitter;
import twitter4j.TwitterFactory;
import twitter4j.auth.*;
public final class ReadTweets {
/**
* Main method.
*
* @param args
* the command line arguments; unused here
*/
public static void main(String[] args) {
Twitter twitter = new TwitterFactory().getInstance();
//consumer key and consumer secret
twitter.setOAuthConsumer("---", "---");
//access token and access token secret
twitter.setOAuthAccessToken(new AccessToken("---", "---"));
try {
ResponseList<Status> a = twitter.getHomeTimeline(new Paging(1,5));
for (Status b : a) {
System.out.println(b.getText());
}
} catch (Exception e) {
System.out.println(e);
}
}
}