Development of Twitter Applications Part 7. Search API

Slides:



Advertisements
Similar presentations
Transparency No. 1 Java Collection API : Built-in Data Structures for Java.
Advertisements

Sequence of characters Generalized form Expresses Pattern of strings in a Generalized notation.
1 Arrays An array is a special kind of object that is used to store a collection of data. The data stored in an array must all be of the same type, whether.
MS-Access XP Lesson 1. Introduction to MS-Access Database Management System Software (DBMS) Store data in databases Database is a collection of table.
The Singleton Pattern II Recursive Linked Structures.
CSCI 160 Midterm Review Rasanjalee DM.
Problem Solving 5 Using Java API for Searching and Sorting Applications ICS-201 Introduction to Computing II Semester 071.
COMP 110 Introduction to Programming Mr. Joshua Stough September 10, 2007.
Online real-time tweets extraction, mapping and dissemination Xiannian Chen and Gregory Elmes West Virginia University Chen & West Virginia University2014.
Java Unit 9: Arrays Declaring and Processing Arrays.
Week 4-5 Java Programming. Loops What is a loop? Loop is code that repeats itself a certain number of times There are two types of loops: For loop Used.
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
Recitation 2 Main Method, API & Packages, Java Basics.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Chapter 8 Cookies And Security JavaScript, Third Edition.
Goals for Today  implement a Deck of Cards  composition  Iterator interface  Iterable interface 1.
CIT 590 Intro to Programming First lecture on Java.
Website Development with PHP and MySQL Saving Data.
Object-Oriented Programming Developing an Application.
4 1 SEARCHING THE WEB Using Search Engines and Directories Effectively New Perspectives on THE INTERNET.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
Rails & Ajax Module 5. Introduction to Rails Overview of Rails Rails is Ruby based “A development framework for Web-based applications” Rails uses the.
Objects & Classes Weiss ch. 3. So far: –Point (see java.awt.Point) –String –Arrays of various kinds –IPAddress (see java.net.InetAddress) The Java API.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
CS 180 Recitation 7 Arrays. Used to store similar values or objects. An array is an indexed collection of data values of the same type. Arrays are the.
©2003 Paula Matuszek GOOGLE API l Search requests: submit a query string and a set of parameters to the Google Web APIs service and receive in return a.
Defining Classes I Part B. Information hiding & encapsulation separate how to use the class from the implementation details separate how to use the class.
Topics Instance variables, set and get methods Encapsulation
Linked Data & Semantic Web Technology Development of Twitter Applications Part 1. Overview Dr. Myungjin Lee.
Linked Data & Semantic Web Technology Development of Twitter Applications Part 4. Timeline and Tweet Dr. Myungjin Lee.
16BIT IITR Data Collection Module A web crawler (also known as a web spider or web robot) is a program or automated script which browses the World Wide.
Linked Data & Semantic Web Technology Development of Twitter Applications Part 6. Trends Dr. Myungjin Lee.
Linked Data & Semantic Web Technology Development of Twitter Applications Part 2. Twitter for Websites Dr. Myungjin Lee.
N5 Databases Notes Information Systems Design & Development: Structures and links.
INTERMEDIATE PROGRAMMING USING JAVA
Tirgul 4 Reference variables Method overloading The keyword “this”
Development of Twitter Applications Part 5. Users
Receiving New Lending requests
OBJECT ORIENTED PROGRAMMING II LECTURE 2 GEORGE KOUTSOGIANNAKIS
Selenium WebDriver Web Test Tool Training
All about social networking
Review Session.
Chapter 3 Selections Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved
Midterm Review Problems
– Introduction to Object Technology
Formatting Output.
Chapter 9 Web Services: JAX-RPC, WSDL, XML Schema, and SOAP
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA
ArraySet Methods and ArrayIterator
Chapter 8 Objects and Classes Part 1
CIS16 Application Development and Programming using Visual Basic.net
PHP.
Uniform Resource Locators (URLs)
Example: LinkedSet<T>
class PrintOnetoTen { public static void main(String args[]) {
OBJECT ORIENTED PROGRAMMING I LECTURE 9 GEORGE KOUTSOGIANNAKIS
Lecture Notes – Week 2 Lecture-2
HTML5 Form Types – Newer Available Fields
QPTM- Nominations.
Suggested self-checks: Section 7.11 #1-11
Special instance methods: toString
Creating and Modifying Text part 3
OO Programming Concepts
Implementing static features
Session - 6 Sequence - 1 SQL: The Structured Query Language:
Information Retrieval and Web Design
Uniform Resource Locators (URLs)
Classes and Objects Object Creation
Development of Twitter Applications Part 3. OAuth
CMSC 202 Constructors Version 9/10.
Presentation transcript:

Development of Twitter Applications Part 7. Search API Dr. Myungjin Lee

Search API Search REST API Limitation 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.

Search Operator 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

GET search/tweets Resource URL Parameters Other Information 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 Restricts tweets to the given language, given by an ISO 639-1 code. Language detection is best-effort. result_type 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 The number of tweets to return per page, up to a maximum of 100. Defaults to 15. until Returns tweets generated before the given date. Date should be formatted as YYYY-MM-DD. since_id Returns results with an ID greater than (that is, more recent than) the specified ID. max_id Returns results with an ID less than (that is, older than) or equal to the specified ID. include_entities The entities node will be disincluded when set to false. callback If supplied, the response will use the JSONP format with a callback of the given name.

Twitter4J Classes for Search SearchResource Interface Methods QueryResult search(Query query) Query Class A data class represents search query. Constructor Query() Query(java.lang.String query) void setCount(int count) void setGeoCode(GeoLocation location, double radius, java.lang.String unit) void setLang(java.lang.String lang) void setLocale(java.lang.String locale) void setMaxId(long maxId) void setQuery(java.lang.String query) void setResultType(java.lang.String resultType) MIXED, POPULAR, RECENT void setSince(java.lang.String since) void setSinceId(long sinceId) void setUntil(java.lang.String until)

Twitter4J Classes for Search QueryResult Interface A data interface representing search API response Methods int getCount() long getMaxId() java.lang.String getQuery() long getSinceId() java.util.List<Status> getTweets() boolean hasNext() Query nextQuery()

Searching Tweets import java.util.List; import twitter4j.Query; import twitter4j.QueryResult; import twitter4j.Status; import twitter4j.Twitter; import twitter4j.TwitterException; import twitter4j.TwitterFactory; public class TwitterSearch { Twitter twitter = null; public TwitterSearch() { this.twitter = TwitterFactory.getSingleton(); this.twitter.setOAuthConsumer(TwitterAccessToken.consumerKey, TwitterAccessToken.consumerSecret); this.twitter.setOAuthAccessToken(TwitterAccessToken.loadAccessToken()); } public static void main(String args[]) throws TwitterException { TwitterSearch tt = new TwitterSearch(); Query q = new Query(); q.setQuery("GentleMan"); q.setResultType(Query.RECENT); q.setCount(100); QueryResult qr = tt.twitter.search(q); List<Status> tweets = qr.getTweets(); for (int i = 0; i < tweets.size(); i++) { Status tweet = tweets.get(i); System.out.println("Text: " + tweet.getText() + ", " + tweet.getCreatedAt() + ", " + tweet.getRetweetCount());