This series of slides describes how to develop a twitter application.
This slide describes how to search tweets using Twitter Search RESTful Open API and how to implement it using Twitter4J.
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Development of Twitter Application #7 - Search
1. Linked Data &
Semantic Web
Technology
Development of
Twitter Applications
Part 7. Search API
Dr. Myungjin Lee
2. Linked Data & Semantic Web Technology
Search API
• Search REST API
– find and return a collection of relevant Tweets based
on matching a specified query
• Limitation
– not complete index of all Tweets, but instead an index
of recent 6-9 days of Tweets
– cannot find Tweets older than about a week.
– limited due to complexity
– not support authentication meaning all queries are
made anonymously.
– focused in relevance and not completeness
– limited to 1,000 characters in query length, including
any operators.
2
3. Linked Data & Semantic Web Technology
Search Operator
3
Example Finds tweets...
twitter search containing both "twitter" and "search". This is the default operator
"happy hour" containing the exact phrase "happy hour"
love OR hate containing either "love" or "hate" (or both)
beer -root containing "beer" but not "root"
#haiku containing the hashtag "haiku"
from:twitterapi sent from the user @twitterapi
to:twitterapi sent to the user @twitterapi
place:opentable:2 about the place with OpenTable ID 2
place:247f43d441defc03 about the place with Twitter ID 247f43d441defc03
@twitterapi mentioning @twitterapi
superhero since:2011-05-09 containing "superhero" and sent since date "2011-05-09"
twitterapi until:2011-05-09 containing "twitterapi" and sent before the date "2011-05-09".
movie -scary :) containing "movie", but not "scary", and with a positive attitude.
flight :( containing "flight" and with a negative attitude.
traffic ? containing "traffic" and asking a question.
hilarious filter:links containing "hilarious" and with a URL.
news source:tweet_button containing "news" and entered via the Tweet Button
4. Linked Data & Semantic Web Technology
GET search/tweets
• Resource URL
– https://api.twitter.com/1.1/search/tweets.json
• Parameters
• Other Information
– Requests per rate limit window: 180/user, 450/app
– Authentication: Required
– Response Object: Tweets
q
required
A UTF-8, URL-encoded search query of 1,000 characters maximum, including
operators. Queries may additionally be limited by complexity.
geocode
optional
Returns tweets by users located within a given radius of the given latitude/longitude.
lang
optional
Restricts tweets to the given language, given by an ISO 639-1 code. Language
detection is best-effort.
result_type
optional
Optional. Specifies what type of search results you would prefer to receive. The
current default is "mixed." Valid values include:
* mixed: Include both popular and real time results in the response.
* recent: return only the most recent results in the response
* popular: return only the most popular results in the response.
count
optional
The number of tweets to return per page, up to a maximum of 100. Defaults to 15.
until
optional
Returns tweets generated before the given date. Date should be formatted as
YYYY-MM-DD.
since_id
optional
Returns results with an ID greater than (that is, more recent than) the specified ID.
max_id
optional
Returns results with an ID less than (that is, older than) or equal to the specified ID.
include_entities
optional
The entities node will be disincluded when set to false.
callback
optional
If supplied, the response will use the JSONP format with a callback of the given
name.
4