21
Linked Data & Semantic Web Technology Development of Twitter Applications Part 1. Overview Dr. Myungjin Lee

Development of Twitter Application #1 - Overview

Embed Size (px)

DESCRIPTION

This series of slides describes how to develop a twitter application. First time, it shows basic knowledge for twitter applications.

Citation preview

  • 1. Linked Data & Semantic Web TechnologyDevelopment of Twitter Applications Part 1. Overview Dr. Myungjin Lee
  • 2. What is Twitter? An information network a real-time information network that connects you to the latest stories, ideas, opinions and news about what you find interesting using small bursts of information called Tweets with 140 characters long 400 million tweet-per-day (June 6, 2012) Open Source base built on open source software, from the back-end to the front-end https://dev.twitter.com/opensource/thanks 2Linked Data & Semantic Web Technology
  • 3. How is Twitter Different from Other Social Tools? not symmetrical symmetrical (nonreciprocal relationships) inherent openness walled garden, protected information cannot edit, just can delete can edit and delete 3Linked Data & Semantic Web Technology
  • 4. Twitter Terms Twitter the service that can communicate with anyone else Tweets messages of 140 characters or fewer Follower someone who opts in to receive your tweets Following the people whose tweets you opt in to receive @reply a public message typically sent as a response to a previous Tweet Direct messages (DMs) a message sent privately to one of your followers Private account an account whose tweets are not public Trending topics the most popular terms on Twitter at a moment in time Retweets (RTs) when users find an interesting tweet and share it with their followers Hashtag the convention of flagging a word with the hash character #topic to aid with keyword search and the tagging of discussions 4Linked Data & Semantic Web Technology
  • 5. Quiz 1. Why is there a character limit in a tweet? A. Twitter decided thats long enough for a thought. B. Twitter wanted to save on server space. C. There is a hard-character limit on SMS. 2. True or False: There are two types of accounts on Twitter: one that is open and another that is closed. 3. What is a direct message, or DM? A. A tweet that doesnt go through Twitters server. B. A private tweet that goes only to the person you are sending it to. C. A message that comes from Twitter corporate 5Linked Data & Semantic Web Technology
  • 6. Services for Twitter Applications Twitter for Websites a suit of products that enables websites to easily integrate Twitter, such as the Like button and the Follow button Search API for products looking to allow a user to query for Twitter content finding a set of tweets with specific keywords, finding tweets referencing a specific user, or finding tweets from a particular user REST API to access some of the core primitives of Twitter including timelines, status updates, and user information offering programmatic access to the timeline, status, and user objects Streaming API the real-time sample of the Twitter Firehose low-latency high volume access to Tweets to establish a long-lived HTTP connection and maintain that connection 6Linked Data & Semantic Web Technology
  • 7. Differences between Streaming and REST REST API Streaming API 7Linked Data & Semantic Web Technology
  • 8. Registering Your Application https://dev.twitter.com/apps/new Application Details Name your application name Description your application description Website your applications publicly accessible home page Callback URL webpage URL where twitter returns after successfully authenticating 8Linked Data & Semantic Web Technology
  • 9. Registering Your Application 9Linked Data & Semantic Web Technology
  • 10. OAuth Process for Desktop Application 10Linked Data & Semantic Web Technology
  • 11. OAuth Process for Web Application 11Linked Data & Semantic Web Technology
  • 12. HTTP Status Codes Code Text Description 200 OK Success! 304 Not Modified There was no new data to return. The request was invalid. An accompanying error message will explain why. This is the status code will be returned 400 Bad Request during version 1.0 rate limiting. In API v1.1, a request without authentication is considered invalid and you will get this response. 401 Unauthorized Authentication credentials were missing or incorrect. The request is understood, but it has been refused or access is not allowed. An accompanying error message will 403 Forbidden explain why. This code is used when requests are being denied due to update limits. The URI requested is invalid or the resource requested, such as a user, does not exists. Also returned when the 404 Not Found requested format is not supported by the requested method. 406 Not Acceptable Returned by the Search API when an invalid format is specified in the request. This resource is gone. Used to indicate that an API endpoint has been turned off. For example: "The Twitter REST 410 Gone API v1 will soon stop functioning. Please migrate to API v1.1." 420 Enhance Your Calm Returned by the version 1 Search and Trends APIs when you are being rate limited. 422 Unprocessable Entity Returned when an image uploaded to POST account/update_profile_banner is unable to be processed. Returned in API v1.1 when a request cannot be served due to the applications rate limit having been exhausted for 429 Too Many Requests the resource. 500 Internal Server Error Something is broken. Please post to the group so the Twitter team can investigate. 502 Bad Gateway Twitter is down or being upgraded. 503 Service Unavailable The Twitter servers are up, but overloaded with requests. Try again later. 504 Gateway timeout The Twitter servers are up, but the request couldnt be serviced due to some failure within our stack. Try again later. 12Linked Data & Semantic Web Technology
  • 13. Error Messages and Codes When the Twitter API returns error messages, it does so in your requested format. {"errors":[{"message":"Sorry, that page does not exist","code":34}]} Code Text Description 32 Could not authenticate you Your call could not be completed as dialed. 34 Sorry, that page does not exist Corresponds with an HTTP 404 - the specified resource was not found. 88 Rate limit exceeded The request limit for this resource has been reached for the current rate limit window. 89 Invalid or expired token The access token used in the request is incorrect or has expired. Used in API v1.1 130 Over capacity Corresponds with an HTTP 503 - Twitter is temporarily over capacity. 131 Internal error Corresponds with an HTTP 500 - An unknown internal error occurred. Corresponds with a HTTP 401 - it means that your oauth_timestamp is either ahead or behind our 135 Could not authenticate you acceptable range Typically sent with 1.1 responses with HTTP code 400. The method requires authentication but it 215 Bad authentication data was not presented or was wholly invalid. 13Linked Data & Semantic Web Technology
  • 14. Twitter Out of the Box Basic Limits for Twitter Applications 1,000 total updates per day, on any and all devices 250 total direct messages per day, on any and all devices Changes to account email: Four per hour Following (daily): The technical follow limit is 1,000 per day. Following (account-based): An account is following 2,000 other users. Whitelisting to provide developers with an increase from 150 to 20,000 requests per hour however, no longer grant whitelisting request 14Linked Data & Semantic Web Technology
  • 15. Rate Limiting REST API Rate Limiting Default rate limit for calls to the REST API Unauthenticated calls are permitted 150 request per hour against the public facing IP of the server or device. OAuth calls are permitted 350 requests per hour against the oauth_token Invalid OAuth information the API For methods which require authentication, the API will return an error response. For methods which can be requested unauthenticated, the request will count against the unauthenticated rate limit. API methods to submit data using HTTP POST are not rate limited. Search API Rate Limiting higher than the REST Rate Limit, sufficient for most application Streaming API rate limiting and access level that are appropriate for long-lived connections 15Linked Data & Semantic Web Technology
  • 16. Rate Limiting Knowing if you are rate limited If your application is being rate-limited by the REST API, it will receive HTTP 400 response codes. If you are rate limited on the Search or Streaming APIs, an HTTP 420 response code will be returned. Blacklisting If you or your application abuses the rate limits we will blacklist it. 1. If you are using the REST API, make a call to the GET application/rate_limit_status from the account or computer which is blacklisted. 2. Explain why you think your application was blacklisted. 3. Describe in detail how you have fixed the problem that you think caused you to be blacklisted. 16Linked Data & Semantic Web Technology
  • 17. Rate Limiting Checking the rate limit Response headers the current rate status in the response header X-RateLimit-Limit: 350 X-RateLimit-Remaining: 350 X-RateLimit-Reset: 1277485629 Request your rate limits from the API an API call to /1.1/application/rate_limit_status.xml or /1.1/application/rate_limit_status.json {"reset_time_in_seconds"=>1277485629, "remaining_hits"=>350, "hourly_limit"=>350, "reset_time"=>"Fri Jun 25 17:07:09 +0000 2010"} 17Linked Data & Semantic Web Technology
  • 18. Things Every Developer Should Know Tweet IDs are enormous and break javascript use the id_str field instead of id The API is entirely HTTP-based basically, require a GET request a POST request to submit, change, or destroy data a DELETE request to destroy data The API is a RESTful resource to support XML, JSON, and the RSS and Atom syndication formats Parameters have certain expectations two things to keep in mind Parameter values should be converted to UTF-8 and URL encoded. The page parameter begins at 1, not 0. two special parameters in the Twitter API callback: to wraps response in a callback method of your choice suppress_response_codes: If this parameter is present, all responses will be returned with a 200 OK status code even errors. 18Linked Data & Semantic Web Technology
  • 19. Twitter Libraries Clojure Objective-C twitter-api FHSTwitterEngine ColdFusion Perl MonkehTweet Twitter API Net::Twitter .NET PHP LINQ2Twitter tmhOAuth Spring.NET Social extension for Twitter twitteroauth TweetSharp 140dev Twitter Framework Go codebird-php twittergo Python Java tweepy Twitter4J python-twitter Javascript / node.js Ruby user-stream Twitter codebird-js Twitter Console Lua/Corona SDK TweetStream Twitter Facade 19Linked Data & Semantic Web Technology
  • 20. Exploring the Twitter API https://apigee.com/embed/console/twitter 20Linked Data & Semantic Web Technology
  • 21. References Christoper Peri, Sams Teach Yourself the Twitter API in 24 Hours, SAMS, June 2011. https://twitter.com/about http://www.theverge.com/2012/6/6/3069424/twitter-400-million-total-daily-tweets https://dev.twitter.com/opensource https://dev.twitter.com/start https://apigee.com/embed/console/twitter 21Linked Data & Semantic Web Technology