JSONObject Error


#1

Hi,

I am using twitter API for the first time and I am using the Twitter4j library. I am always getting the below error when I run my code:

Exception in thread “main” A JSONObject text must begin with ‘{’ found

Here is the code:

	//Your Twitter App's Consumer Key
		String consumerKey = "***";

		//Your Twitter App's Consumer Secret
		String consumerSecret = "***";

		//Your Twitter Access Token
		String accessToken = "***";

		//Your Twitter Access Token Secret
		String accessTokenSecret = "***";
		ConfigurationBuilder cb = new ConfigurationBuilder();
		cb.setDebugEnabled(true);
		cb.setOAuthConsumerKey(consumerKey);
		cb.setOAuthConsumerSecret(consumerSecret);
		cb.setOAuthAccessToken(accessToken);
		cb.setOAuthAccessTokenSecret(accessTokenSecret);
		TwitterFactory tf = new TwitterFactory(cb.build());
		
		 // The factory instance is re-useable and thread safe.
		Twitter twitter = tf.getInstance();
		twitter.getUserTimeline();

The error is thrown at the last line. I’ve tried to find solutions to this on google but can’t find anything. It does seem that Twitter is not returning the response in the format that it should be.

Kindly help.