FAQ Database Discussion Community


twitter4j twitterobjectfactory.createstatus returns retweetedStatus as null

java,json,twitter4j
I have been storing a considerable amount of Tweets in JSon format. Now that I'm attempting to read them back into Status, the object creation only fills in some of the fields, even though the raw Json contains all of the information. Here is the raw JSON {"createdAt":"Aug 5, 2014...

Getting original tweet-id and user-id from retweet-id

twitter,twitter4j,twitter-streaming-api
I am using Twitter4j to access the streaming API. I am using follow, to get a stream related to a set of users. My problem basically boils down to this: Given a retweet (I have the retweet-id and the user-id of the retweet) in the stream, how can I find:...

Twitter4j - cannot resolve method - setUsessl(boolean)

android,android-studio,twitter4j
I'm using twitter4j 4.0.3 core I have this code: public final class TwitterUtil { private RequestToken requestToken = null; private TwitterFactory twitterFactory = null; private Twitter twitter; private TwitterUtil() { ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.setOAuthConsumerKey(ConstantValues.TWITTER_CONSUMER_KEY); configurationBuilder.setOAuthConsumerSecret(ConstantValues.TWITTER_CONSUMER_SECRET); configurationBuilder.setUseSSL(true); Configuration configuration =...

Twitter4j Stream to get own profile tweets

android,twitter,twitter4j
I am trying to use the twitter4j api to retrieve my own tweets only (ie, every 3 sec). After using the manual "ResponseList statuses = twitter.getHomeTimeline();" , i encountered a problem which the request rate was capped. The solution i can find is to use stream service. Right now, my...

Testing Twitter4J with PowerMock

java,twitter4j,powermock
I'm trying to mock the following code using PowerMock Twitter twitter = TwitterFactory.getSingleton(); RequestToken requestToken = twitter.getOAuthRequestToken(); Here is the start of my unit test @RunWith(PowerMockRunner.class) @PrepareForTest(TwitterFactory.class) public class AuthorisationHelperTest { @Test public void testMain() throws TwitterException { // Arrange PowerMockito.mockStatic(TwitterFactory.class); Twitter mockTwitter = new Twitter(); Mockito.when(TwitterFactory.getSingleton()).thenReturn(mockTwitter); However I get...

Requested Resource is not available error

java,jsp,servlets,twitter4j
I'm trying to build a twitter search using jsp, servlet, Tomcat-6.0.43 and eclipse and getting HTTP Status 404 error. Can anyone please check where am I going wrong. My Code: first.jsp: <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html;...

Unable to post twitter status updates with error “no trusted certificate found”

java,ssl,twitter,ssl-certificate,twitter4j
I have a java process that is using Twitter4J to post an update to twitter. I have all the appropriate tokens and keys. When I attempt to post the update I get this error. I have seen that Twitter has updated it's certificates last year and I have added Verisign's...

When adding dependency: CDI deployment failure, Unsatisfied dependencies for type Set with qualifiers @Default

maven,twitter,glassfish,twitter4j,twitter-hbc
When I add the twitter hbc dependency to my pom.xml I'm getting an error. I followed the instructions from here. I don't get it, if it was a dependency problem I should have found a fix on the web but if I comment out that dependency, my server is starting.....

twitter4j geo streaming latitude/longitude for Hongkong

java,twitter,latitude-longitude,twitter4j
I'm trying to capture tweets using twitter4j's streaming methods from the area of Hongkong. However not matter what latitude or longitude coordinates I choose to do so (from http://www.latlong.net/convert-address-to-lat-long.html) I always get invalid latitude/longitude error. Latitude/longitude are not valid: 22.27, 114.17, 22.35, 114.21 The code I use is otherwise working...

Get Twitter's profiles using Java

java,twitter,profile,twitter4j
I'm doing an app which using Java with Twitter4j, I want to access to other Twitter user's profile information (id,name, etc) but these users are not followers or friends of mine. Now I only can access of my follower's and friend's profiles. Here is my code (to access to my...

Streaming data with Spring MVC

java,spring,spring-mvc,twitter,twitter4j
I'm looking to set up a Twitter stream using Twitter4J. I plan to be able to search using a keyword. I also would like to use Spring MVC as this is something I've used a lot recently. However, I would like to stream an infinite amount of tweets without stopping...

ScrollArea and ScrollBar not working

java,twitter,twitter4j
I've been trying to make a java swing based application to retrieve tweets from a user by using twitter4j..the code seems to be working when pretend on the console but not adding ..i've tried adding the scroll area and scroll bar to help with text wrapping and longer texts but...

Java 8 for Twitter4J 4.0.3

java-8,twitter4j
I'm working on a project using Twitter4J and I'm using the latest version (4.0.3). When using the GET search/tweets endpoint, it takes a long time before I can see the result of my call on the endpoint. So I need to use Java 8 Stream library, so that I can...

Java code to fetch the twitter followers of any user using twitter screen name

java,twitter,twitter4j
I tried to get the twitter followers using the screen name. But i am able to get only my followers screen names where as i am expecting the followers of my followers. But i didn't found any supported method for this. My code is as follows. TwitterFactory factory = new...

StatusListener in twitter4j not listening correctly

java,twitter,twitter4j
Trying to use StatusListener in twitter4j for listening to tweets from a particular user, and then respond to them. But StatusListener seems to be unreliable. It seems to "hear" certain tweets but not others. For instance when the user i am listening to sends a tweet, only sometimes does it...

How to search for multiple twitter ids in one request using twitter4j library

twitter,twitter4j
How to search for multiple twitter ids in one request using twitter4j library. Even using in clause in Search parameter would be helpful. Please help!

createstream of tweets in Spark

scala,stream,apache-spark,twitter4j,tweets
I'm trying to create a stream of tweets in Spark using Scala and Twitter4j. This is a snippet of my code: object auth{ val config = new twitter4j.conf.ConfigurationBuilder() .setOAuthConsumerKey("") .setOAuthConsumerSecret("") .setOAuthAccessToken("") .setOAuthAccessTokenSecret("") .build } val conf = new SparkConf().setMaster("local[2]").setAppName("Tutorial") val ssc = new StreamingContext(conf, Seconds(1)) val twitter_auth = new TwitterFactory(auth.config)...

Index if not exists using bulk processor in elasticsearch

twitter,elasticsearch,twitter4j,twitter-streaming-api
I am trying to index a document if it doesn't already exist in elasticsearch. I am using BulkProcessor when indexing my documents and using Requests.add action. I will have the exact same id sometimes, does it not add automatically, but update? P.S. Update is not a requirement, it can stay...

fill a file inside a inner class

java,file,twitter4j
I'm quiet new to java and I'm not even sure if the title makes any sense. Anyway how do I gain access to a file inside of onStatus? I'm just trying to write into a file in that function so in the code below "T_file.length()" the "T_file" cannot be resolved....

Twitter4J: How to solve the rate limit request of Twitter API?

java,twitter,twitter4j
I am creating a java application that interact with Twitter using the library Twitter4J. I want to download 10 000 nodes from twitter, and then do the statistics on the graph created. The graph is initially saved in a dataset (.txt file). I must also save enough ReTweet for each...

Android data is lost onCreate() after startActivity() for callback

android,twitter4j,android-lifecycle,activity-lifecycle,datapersistance
I have an android app which connects to twitter via twitter4j. In an activity there is a share button and a TextView. The flow is like below; User opens the activity starting onCreate() which populates the TextView User clicks "Share" Twitter activity is started for oAuth, user types account credentials...

how can i get English tweets only using java?

java,twitter,twitter4j
here the code public void onStatus(Status status) { String lang = status.getUser().getLang(); if (tweetCount < 50000) { if (lang.equals("en")) { storeInFile(status); tweetCount++; } } } tweets i get from all the languages. Is there a way to restrict myself to fetching tweets only in English?...

How to run Processing+Twitter4j sketch in broswer

javascript,html,processing,twitter4j
I'm a newbie programmer practicing Processing and I recently developed a sketch that uses Twitter4j. When I run the sketch in Java mode from the Processing Development Environment it works perfectly. Also, when I export the sketch from Java mode the resulting application runs perfectly. However, when I switch to...

With Twitter4j, how do I wait for all async calls to finish?

java,multithreading,asynchronous,twitter4j
This example shows how to use the async methods of Twitter4j to make requests to the Twitter API, but it only makes one request. I want to be able to fire multiple queries to the API, execute them asynchronously and wait for them to finish before exiting the program. Since...

Twitter4j , searching for tweets with keyword

android,twitter,twitter4j
I am making a twitter project, to search all the public tweets with a specific keyword. The following crashes my app: private void searchTweets() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true) .setOAuthConsumerKey(getString(R.string.twitter_consumer_key)) .setOAuthConsumerSecret(getString(R.string.twitter_consumer_secret)) .setOAuthAccessToken(getString(R.string.twitter_access_token)) .setOAuthAccessTokenSecret(getString(R.string.twitter_token_secret)); TwitterFactory tf = new...

filtering out users using TwitterUtils

java,twitter4j,spark-streaming,twitter-util
Is there a way to extract only specific user who post a tweet when using TwitterUtils.createStream()? (JAVA) The "filters" argument specifies the strings that need to be contained in the tweets, but I am not sure how this can be used to specify the user who interest me. i have...

Twitter4J Creating Callback URL That Goes Back To My App

java,android,twitter,callback,twitter4j
I've read through this: Android: Login with Twitter using Twitter4J And the selected answer doesn't make sense in the context that I need it. I want the user to be able to login to their Twitter account from our app, and then, once they've logged in, I want our app...

How to getIntent().getData(); on Fragment

android,android-fragments,twitter-oauth,twitter4j
On my application is use login with twitter, in example code work in Activity but my app use work in Fragment Click login with twitter button Go to web browser for Authorize application Back to application Feeds(use fragment) & show Toast twitter_id How to edit error on Uri uri =...

Rate limit exceeded with Twitter4j

java,twitter,twitter4j
I'm using this example for pulling tweets from Twitter. I am getting the error below due to rate limit reached. How do I set the rate? 429:Returned in API v1.1 when a request cannot be served due to the application's rate limit having been exhausted for the resource. See Rate...

Get country from tweet with certain keywords

java,twitter4j,cloudera,flume
I am using TwitterSource for Flume from Cloudera. I want to get tweets by country with certain keywords. I'm not sure what to compare to when I want to get tweets from The Netherlands. I have the following which results in nothing being processed: public void onStatus(Status status) { if(status.getPlace().getCountry().equalsIgnoreCase("netherlands"))...