Search in sources :

Example 1 with Status

use of twitter4j.Status in project tdi-studio-se by Talend.

the class TwitterLoad method twitterStream.

public static JavaDStream<List<Object>> twitterStream(JavaStreamingContext ctx, String username, String password, String accessToken, String secretToken, String[] filters, List<TwitterParameter> twitterParameters) {
    twitter4j.conf.ConfigurationBuilder builder = new ConfigurationBuilder();
    builder.setOAuthAccessToken(accessToken);
    builder.setOAuthAccessTokenSecret(secretToken);
    builder.setOAuthConsumerKey(username);
    builder.setOAuthConsumerSecret(password);
    JavaDStream<Status> inputDStream = null;
    if (filters.length > 0) {
        if (filters.length == 1 && filters[0].equals(""))
            inputDStream = TwitterUtils.createStream(ctx, new OAuthAuthorization(builder.build()));
        else
            inputDStream = TwitterUtils.createStream(ctx, new OAuthAuthorization(builder.build()), filters);
        return inputDStream.map(new LoadTwitterFunction(twitterParameters));
    }
    return null;
}
Also used : Status(twitter4j.Status) ConfigurationBuilder(twitter4j.conf.ConfigurationBuilder) ConfigurationBuilder(twitter4j.conf.ConfigurationBuilder) LoadTwitterFunction(org.talend.spark.function.LoadTwitterFunction) OAuthAuthorization(twitter4j.auth.OAuthAuthorization)

Example 2 with Status

use of twitter4j.Status in project quorrabot by GloriousEggroll.

the class TwitterAPI method getlast.

public static String getlast() {
    try {
        List<Status> statuses = twitter.getUserTimeline();
        Status status = statuses.get(0);
        return status.getText();
    } catch (TwitterException te) {
        te.printStackTrace();
        return null;
    }
}
Also used : Status(twitter4j.Status) TwitterException(twitter4j.TwitterException)

Example 3 with Status

use of twitter4j.Status in project asterixdb by apache.

the class TwitterPullRecordReader method next.

@Override
public IRawRecord<String> next() throws IOException, InterruptedException {
    if (result == null || nextTweetIndex >= result.getTweets().size()) {
        Thread.sleep(1000 * requestInterval);
        query.setSinceId(lastTweetIdReceived);
        try {
            result = twitter.search(query);
        } catch (TwitterException e) {
            throw new HyracksDataException(e);
        }
        nextTweetIndex = 0;
    }
    if (result != null && !result.getTweets().isEmpty()) {
        List<Status> tw = result.getTweets();
        Status tweet = tw.get(nextTweetIndex++);
        if (lastTweetIdReceived < tweet.getId()) {
            lastTweetIdReceived = tweet.getId();
        }
        // transform tweet obj to json
        String jsonTweet = TwitterObjectFactory.getRawJSON(tweet);
        record.set(jsonTweet);
        return record;
    } else {
        return null;
    }
}
Also used : Status(twitter4j.Status) TwitterException(twitter4j.TwitterException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 4 with Status

use of twitter4j.Status in project camel by apache.

the class UserProducer method updateStatus.

private Status updateStatus(StatusUpdate status) throws Exception {
    Status response = endpoint.getProperties().getTwitter().updateStatus(status);
    log.debug("Updated status: {}", status);
    log.debug("Status id: {}", response.getId());
    return response;
}
Also used : Status(twitter4j.Status)

Example 5 with Status

use of twitter4j.Status in project camel by apache.

the class UserProducer method process.

@Override
public void process(Exchange exchange) throws Exception {
    // update user's status
    Object in = exchange.getIn().getBody();
    Status response;
    if (in instanceof StatusUpdate) {
        response = updateStatus((StatusUpdate) in);
    } else {
        String s = exchange.getIn().getMandatoryBody(String.class);
        response = updateStatus(s);
    }
    /*
         * Support the InOut exchange pattern in order to provide access to
         * the unique identifier for the published tweet which is returned in the response
         * by the Twitter REST API: https://dev.twitter.com/docs/api/1/post/statuses/update
         */
    if (exchange.getPattern().isOutCapable()) {
        // here we just copy the header of in message to the out message
        exchange.getOut().copyFrom(exchange.getIn());
        exchange.getOut().setBody(response);
    }
}
Also used : Status(twitter4j.Status) StatusUpdate(twitter4j.StatusUpdate)

Aggregations

Status (twitter4j.Status)108 Twitter (twitter4j.Twitter)47 TwitterException (twitter4j.TwitterException)40 ArrayList (java.util.ArrayList)22 Activity (android.app.Activity)20 QueryResult (twitter4j.QueryResult)19 User (twitter4j.User)14 TimelineArrayAdapter (com.klinker.android.twitter.adapters.TimelineArrayAdapter)13 Query (twitter4j.Query)13 Intent (android.content.Intent)11 Context (android.content.Context)10 Paging (twitter4j.Paging)10 TwitterFactory (twitter4j.TwitterFactory)10 View (android.view.View)9 IOException (java.io.IOException)9 ContentValues (android.content.ContentValues)7 Toast (android.widget.Toast)6 TwitterStringUtils (com.github.moko256.twicalico.text.TwitterStringUtils)6 Single (rx.Single)6 AndroidSchedulers (rx.android.schedulers.AndroidSchedulers)6