Closed ashvani1 closed 2 years ago
Hope, you have found the answer to this already. If not, please try the below steps for authentication; it will work:
// sample code // generate the OAuth Access token first and then set it with twitter handle twitter = new TwitterFactory().getInstance(); twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET_KEY); AccessToken oauthAccessToken = new AccessToken(getSavedAccessToken(), getSavedAccessTokenSecret()); twitter.setOAuthAccessToken(oauthAccessToken);
I assume, you have saved the access Token and access token secret from our twitter App - permissions page already. Use them to supply getSavedAccessToken() getSavedAccessTokenSecret()
Hope this helps.
This should be resolved, @ubarpsi solution worked!
import java.util.List; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit;
import org.slf4j.Logger; import org.slf4j.LoggerFactory;
import com.google.common.collect.Lists; import com.twitter.hbc.ClientBuilder; import com.twitter.hbc.core.Client; import com.twitter.hbc.core.Constants; import com.twitter.hbc.core.Hosts; import com.twitter.hbc.core.HttpHosts; import com.twitter.hbc.core.endpoint.StatusesFilterEndpoint; import com.twitter.hbc.core.processor.StringDelimitedProcessor; import com.twitter.hbc.httpclient.auth.Authentication; import com.twitter.hbc.httpclient.auth.OAuth1;
public class TwitterProducer { Logger logger = LoggerFactory.getLogger(TwitterProducer.class.getName()); String consumerKey = "V1pedBFKWPM2zXqzoFzUOPNrL"; String consumerSecret = "2RsTvxFtZVZFe2FFU2KGqLglhPu8cia2JvTXPCYRfUswP36Td6"; String token = "555591025-555591025-MrPsbVxBNiNrAUBnkzHKYy8AnJahRtzHsjSZwzqz"; String secret = "7F4Y9PYzAdpg0l90BeaLOBnr5Jn2sIMxNz1HK4OMYAOaK";
}