/** * returns tweets by users located within a given radius of the given latitude/longitude, where the user's location is taken from their Twitter profile * * @param location geo location * @param radius radius * @param unit Query.MILES or Query.KILOMETERS * @return the instance * @since Twitter4J 4.0.7 */ public Query geoCode(GeoLocation location, double radius , Unit unit) { setGeoCode(location, radius, unit); return this; }
/** * returns tweets with status ids greater than the given id. * * @param sinceId returns tweets with status ids greater than the given id * @return the instance * @since Twitter4J 2.1.0 */ public Query sinceId(long sinceId) { setSinceId(sinceId); return this; }
/*package*/ QueryResult(Query query) throws TwitterException { super(); sinceId = query.getSinceId(); resultsPerPage = query.getRpp(); page = query.getPage(); tweets = new ArrayList<Tweet>(0); }
/*package*/ QueryResultJSONImpl(Query query) { super(); sinceId = query.getSinceId(); count = query.getCount(); tweets = new ArrayList<Status>(0); }
@Optional String until, @Optional String resultType) throws TwitterException { final Query q = new Query(query); q.setLang(lang); q.setLocale(locale); q.setMaxId(maxId.longValue()); q.setSince(since); q.setSinceId(sinceId.longValue()); final double latitude = Double.parseDouble(StringUtils.replace(geocodeSplit[0], " ", "")); final double longitude = Double.parseDouble(StringUtils.replace(geocodeSplit[1], " ", "")); q.setGeoCode(new GeoLocation(latitude, longitude), Double.parseDouble(radius), unit); q.setUntil(until); q.setResultType(resultType);
/* package */ static Query createWithNextPageQuery(String nextPageQuery) { Query query = new Query(); query.nextPageQuery = nextPageQuery; query.setQuery(params.get("q")); if(params.containsKey("lang")) query.setLang(params.get("lang")); if(params.containsKey("locale")) query.setLocale(params.get("locale")); if(params.containsKey("max_id")) query.setMaxId(Long.parseLong(params.get("max_id"))); if(params.containsKey("count")) query.setCount(Integer.parseInt(params.get("count"))); if(params.containsKey("geocode")) { String[] parts=params.get("geocode").split(","); throw new IllegalArgumentException("unrecognized geocode radius: "+radiusstr); query.setGeoCode(new GeoLocation(latitude, longitude), radius, unit); query.setResultType(Query.ResultType.valueOf(params.get("result_type")));
Query query = new Query(keywords); query.setSinceId(myLastId); query.setSinceId(sinceId); query.setMaxId(maxId); query.setLang(lang); query.setCount(count);
public List<Exchange> directConsume() throws TwitterException { String keywords = this.keywords; if (keywords == null || keywords.trim().length() == 0) { return Collections.emptyList(); } Query query = new Query(keywords); LOG.debug("Searching twitter with keywords: {}", keywords); return search(query); }
public List<Exchange> pollConsume() throws TwitterException { String keywords = this.keywords; Query query; if (keywords != null && keywords.trim().length() > 0) { query = new Query(keywords); LOG.debug("Searching twitter with keywords: {}", keywords); } else { query = new Query(); LOG.debug("Searching twitter without keywords."); } if (endpoint.getProperties().isFilterOld()) { query.setSinceId(getLastId()); } return search(query); }
query.setLang(endpoint.getProperties().getLang()); query.setCount(endpoint.getProperties().getCount()); && ObjectHelper.isNotEmpty(endpoint.getProperties().getRadius())) { GeoLocation location = new GeoLocation(endpoint.getProperties().getLatitude(), endpoint.getProperties().getLongitude()); query.setGeoCode(location, endpoint.getProperties().getRadius(), Unit.valueOf(endpoint.getProperties().getDistanceMetric()));
private static List<Query> geoLocQueries(List<Map<String, String>> geolocs) { final List<Query> ret = new ArrayList<Query>(); for (final Map<String, String> geoloc : geolocs) { final Query q = new Query(); q.geoCode( new GeoLocation( Double.parseDouble(geoloc.get("lat")), Double.parseDouble(geoloc.get("lon")) ), Double.parseDouble(geoloc.get("rad")), Query.KILOMETERS ); ret.add(q); } return ret; } }
/** * sets the number of tweets to return per page, up to a max of 100 * * @param count the number of tweets to return per page * @return the instance * @since Twitter4J 2.1.0 */ public Query count(int count) { setCount(count); return this; }
/** * If specified, returns tweets with status ids less than the given id. * * @param maxId maxId * @return this instance * @since Twitter4J 2.1.1 */ public Query maxId(long maxId) { setMaxId(maxId); return this; }
/** * restricts tweets to the given language, given by an <a href="http://en.wikipedia.org/wiki/ISO_639-1">ISO 639-1 code</a> * * @param lang an <a href="http://en.wikipedia.org/wiki/ISO_639-1">ISO 639-1 code</a> * @return the instance * @since Twitter4J 2.1.0 */ public Query lang(String lang) { setLang(lang); return this; }
public PostParameter[] asPostParameters(){ ArrayList<PostParameter> params = new ArrayList<PostParameter>(); appendParameter("q", query, params); appendParameter("lang", lang, params); appendParameter("rpp",rpp , params); appendParameter("page", page, params); appendParameter("since_id",sinceId , params); appendParameter("geocode", geocode, params); PostParameter[] paramArray = new PostParameter[params.size()]; return params.toArray(paramArray); }
/** * Specify the language of the query you are sending (only ja is currently effective). This is intended for language-specific clients and the default should work in the majority of cases. * * @param locale the locale * @return the instance * @since Twitter4J 2.1.1 */ public Query locale(String locale) { setLocale(locale); return this; }
@Override protected List<twitter4j.Status> doInBackground(String... params) { Twitter twitter = TwitterWrapper.getTwitterInstance(context.getApplicationContext()); List<twitter4j.Status> tweets = null; try { Query query = new Query(params[0]); QueryResult result; result = twitter.search(query); tweets = result.getTweets(); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to search tweets: " + te.getMessage()); } return tweets; }
private static List<Query> geoLocQueries(List<Map<String, String>> geolocs) { final List<Query> ret = new ArrayList<Query>(); for (final Map<String, String> geoloc : geolocs) { final Query q = new Query(); q.geoCode( new GeoLocation( Double.parseDouble(geoloc.get("lat")), Double.parseDouble(geoloc.get("lon")) ), Double.parseDouble(geoloc.get("rad")), Query.KILOMETERS ); ret.add(q); } return ret; } }