|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.twitterapime.search.SearchDevice
public final class SearchDevice
This class is the entry point of Search API, which defines the methods responsible for submitting a query to Twitter Search API.
SearchDevice sd = SearchDevice.getInstance(); Query q1 = QueryComposer.from("twitteruser"); Query q2 = QueryComposer.containAny("search api"); Query q = QueryComposer.append(q1, q2); Tweet[] ts = sd.searchTweets(q); for (int i = 0; i < ts.length; i++) { list.append(ts[i].getString(MetadataSet.TWEET_CONTENT), null); }
SearchDeviceListener
,
QueryComposer
Field Summary | |
---|---|
static java.lang.String |
TWITTER_API_URL_SERVICE_ACCOUNT_RATE_LIMIT_STATUS
Key for Twitter API URL service account rate limit status. |
static java.lang.String |
TWITTER_API_URL_SERVICE_SEARCH
Key for Twitter API URL service search. |
Method Summary | |
---|---|
int |
getAPICallsCount()
Get the calls count submitted to Twitter Search API since the API was loaded by class loader. |
static SearchDevice |
getInstance()
Get an instance of SearchDevice class. |
long |
getLastAPICallTime()
Get the time at which the last call was submitted to Twitter Search API. |
RateLimitStatus |
getRateLimitStatus()
Return a set of info about the number of API requests available to the requesting IP address before the REST API limit is reached for the current hour. |
Tweet[] |
searchTweets(Query query)
Search for tweets that match the given query. |
Tweet[] |
searchTweets(java.lang.String queryString)
Search for tweets that match the given query string. |
void |
setServiceURL(java.lang.String serviceKey,
java.lang.String url)
Set a new URL to a given Twitter API service. |
void |
startSearchTweets(Query query,
SearchDeviceListener listener)
Search for tweets that match the given query. |
void |
startSearchTweets(java.lang.String queryString,
SearchDeviceListener listener)
Search for tweets that match the given query string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String TWITTER_API_URL_SERVICE_SEARCH
Key for Twitter API URL service search.
setServiceURL(String, String)
,
searchTweets(Query)
,
searchTweets(String)
,
startSearchTweets(Query, SearchDeviceListener)
,
startSearchTweets(String, SearchDeviceListener)
,
Constant Field Valuespublic static final java.lang.String TWITTER_API_URL_SERVICE_ACCOUNT_RATE_LIMIT_STATUS
Key for Twitter API URL service account rate limit status.
setServiceURL(String, String)
,
getRateLimitStatus()
,
Constant Field ValuesMethod Detail |
---|
public void setServiceURL(java.lang.String serviceKey, java.lang.String url)
Set a new URL to a given Twitter API service. This method is very useful in case Twitter API decides to change a service's URL. So there is no need to wait for a new version of this API to get it working back.
Be careful about using this method, since it can cause unexpected results, case you enter an invalid URL.
serviceKey
- Service key.url
- New URL.TWITTER_API_URL_SERVICE_SEARCH
,
TWITTER_API_URL_SERVICE_ACCOUNT_RATE_LIMIT_STATUS
public static SearchDevice getInstance()
Get an instance of SearchDevice class.
public Tweet[] searchTweets(Query query) throws java.io.IOException, LimitExceededException
Search for tweets that match the given query. This method gets blocked until the search is completed or an exception is thrown.
query
- The query.
java.io.IOException
- If an I/O error occurs.
LimitExceededException
- If the limit of access is exceeded.
java.lang.IllegalArgumentException
- If query is null.public Tweet[] searchTweets(java.lang.String queryString) throws java.io.IOException, LimitExceededException
Search for tweets that match the given query string. This method gets blocked until the search is completed or an exception is thrown.
queryString
- The query string.
java.io.IOException
- If an I/O error occurs.
LimitExceededException
- If the limit of access is exceeded.
java.lang.IllegalArgumentException
- If queryString is null/empty.public void startSearchTweets(Query query, SearchDeviceListener listener)
Search for tweets that match the given query. This method does not wait for the search process is completed to return. To have access to this search's result, a SearchDeviceListener object must be registered.
query
- The query.listener
- Listener object to be notified about the search's result.
java.lang.IllegalArgumentException
- If query is null.public void startSearchTweets(java.lang.String queryString, SearchDeviceListener listener)
Search for tweets that match the given query string. This method does not wait for the search process is completed to return. To have access to this search's result, a SearchDeviceListener object must be registered.
queryString
- The query string.listener
- Listener object to be notified about the search's result.
java.lang.IllegalArgumentException
- If queryString is null/empty.public RateLimitStatus getRateLimitStatus() throws java.io.IOException, LimitExceededException
Return a set of info about the number of API requests available to the requesting IP address before the REST API limit is reached for the current hour.
Stay aware of these limits, since it can impact the usage of some methods of this API.
java.io.IOException
- If an I/O error occurs.
LimitExceededException
- If limit has been hit.getAPICallsCount()
public int getAPICallsCount()
Get the calls count submitted to Twitter Search API since the API was loaded by class loader. So this number is reseted when the API is unloaded.
getRateLimitStatus()
public long getLastAPICallTime()
Get the time at which the last call was submitted to Twitter Search API.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |