Twitter 研究会2012-1-28 - Twitter APIの紹介

  • 3,112 views
Uploaded on

 

More in: Technology , Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
3,112
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
27
Comments
0
Likes
7

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Twitter API 2012/01/28 Twitter4J - Copyright(c) Yusuke Yamamoto All rights reserved.
  • 2. @yusukey Copyright(c) Yusuke Yamamoto All rights reserved.
  • 3. Java Twitter API
  • 4. Twitter API Copyright(c) Yusuke Yamamoto All rights reserved.
  • 5. Twi$erAPI RESTAPI : API :Java,Objec8ve9C API StreamedTweets , Java,Python,PHP,Ruby,Objec8ve9C Web API WebIntents :Web @Anywhere :HTML,JavaScript Copyright(c) Yusuke Yamamoto All rights reserved. 5
  • 6. Twitter API Copyright(c) Yusuke Yamamoto All rights reserved.
  • 7. Twitter API•• OAuth• Copyright(c) Yusuke Yamamoto All rights reserved.
  • 8. • Twitter•• Copyright(c) Yusuke Yamamoto All rights reserved.
  • 9. • https://dev.twitter.com/apps/new Copyright(c) Yusuke Yamamoto All rights reserved.
  • 10. Application Type : Copyright(c) Yusuke Yamamoto All rights reserved.
  • 11. Read, Write, & Read & Write Read only Access direct messages ○ ○ ○ ○ ○ × ○ ○ × ○ × ×Copyright(c) Yusuke Yamamoto All rights reserved.
  • 12. OAuthCopyright(c) Yusuke Yamamoto All rights reserved.
  • 13. Sign in with Twitter Copyright(c) Yusuke Yamamoto All rights reserved.
  • 14. XAuthCopyright(c) Yusuke Yamamoto All rights reserved.
  • 15. REST APICopyright(c) Yusuke Yamamoto All rights reserved.
  • 16. REST API • REST: REpresentational State Transfer • HTTP APIGET /1/statuses/public_timeline.json HTTP/1.1Host: api.twitter.comHTTP/1.1 200 OKDate: Tue, 08 Feb 2011 07:52:51 GMTServer: hiStatus: 200 OKContent-Type: application/json; charset=utf-8Vary: Accept-EncodingConnection: close[{"source": "<a href="http://foursquare.com" rel="nofollow">foursquare</a>", "text": "Im at IKEA ( 2-2-2, ) [pic]: http://4sq.com/eOHZdS", ... "user": { "description": "Java rn Java rn#twitter4j#samurai", "name": " ", ...} }, ...] Copyright(c) Yusuke Yamamoto All rights reserved. 16
  • 17. Twitter REST API • 100 • 20 •Timeline http://api.twitter.com/statuses/***.jsonUser http://api.twitter.com/users/***.jsonDirect message http://api.twitter.com/direct_messages/***.json Copyright(c) Yusuke Yamamoto All rights reserved.
  • 18. APICopyright(c) Yusuke Yamamoto All rights reserved.
  • 19. API• ‣• https://twitter.com/#!/search-home Copyright(c) Yusuke Yamamoto All rights reserved. 19
  • 20. API• (GET)‣ http://search.twitter.com/search.json?q=****•q q: #twtr_hack q=#twtr_hack @yusukey #twtr_hack q=#twtr_hack+from:yusukey Copyright(c) Yusuke Yamamoto All rights reserved. 20
  • 21. Query query = new Query(term); query.rpp(100);do { QueryResult qr = twitter.search(query); tweets = qr.getTweets(); for (Tweet tweet : tweets) { // ... } if (tweets.size() != 0) { query.setMaxId(tweets.get(tweets.size() - 1).getId() - 1); }} while (tweets.size() != 0); rpp 100 page 15 1500 →max_id ok Twitter4J Copyright(c) Yusuke Yamamoto All rights reserved. 21
  • 22. APICopyright(c) Yusuke Yamamoto All rights reserved.
  • 23. API• DM• • REST API• • HTTP • • comet WebSocket Copyright(c) Yusuke Yamamoto All rights reserved.
  • 24. $ wget --output-document=- --user=*** --password=*** https://stream.twitter.com/1/statuses/sample.json Copyright(c) Yusuke Yamamoto All rights reserved.
  • 25. API• Streamed Tweets •• User Stream •• Site Stream • Copyright(c) Yusuke Yamamoto All rights reserved.
  • 26. sample• 1%• (GET)‣ https://stream.twitter.com/1/statuses/sample.json•‣•‣ status json (REST API ) Copyright(c) Yusuke Yamamoto All rights reserved.
  • 27. sample• • ‣ ‣ ‣ • Copyright(c) Yusuke Yamamoto All rights reserved.
  • 28. FAQ• sample.json • % Copyright(c) Yusuke Yamamoto All rights reserved.
  • 29. filter • • (POST)‣ https://stream.twitter.com/1/statuses/filter.json •‣ follow, track, locations •‣ status json (REST API ) Copyright(c) Yusuke Yamamoto All rights reserved.
  • 30. User Stream•• : • DM fav / follow • • OAuth( or XAuth) Copyright(c) Yusuke Yamamoto All rights reserved.
  • 31. Site Stream(beta)•• : Twitter • DM fav / follow • • OAuth Copyright(c) Yusuke Yamamoto All rights reserved.
  • 32. Site Stream• 100 • OAuth• • 1 1000 Copyright(c) Yusuke Yamamoto All rights reserved.
  • 33. • Site Stream {"control": { "control_uri":"/2b/site/c/1_1_54e345d655ee3e8d" }} • REST https://sitestream.twitter.com/2b/site/c/1_1_54e345d655ee3e8d"https://dev.twitter.com/docs/streaming-api/control-streams Copyright(c) Yusuke Yamamoto All rights reserved.
  • 34. • • REST API Streaming API• gzip •• • 3G Copyright(c) Yusuke Yamamoto All rights reserved.
  • 35. FAQ• API JavaScript •• 1% • http://gnip.com/• firehose • Copyright(c) Yusuke Yamamoto All rights reserved.
  • 36. Web API Copyright(c) Yusuke Yamamoto All rights reserved.
  • 37. Web Intents • Twitter<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script><a href="http://twitter.com/intent/retweet?tweet_id=163049746431348736"> </a> http://bit.ly/web-intents Copyright(c) Yusuke Yamamoto All rights reserved.
  • 38. @Anywhere• JavaScript Twitter Copyright(c) Yusuke Yamamoto All rights reserved.
  • 39. @Anywhere@yusukey<script type="text/javascript"> twttr.anywhere(function (T) { T.hovercards({expanded:true}); });</script> http://bit.ly/hover-cards Copyright(c) Yusuke Yamamoto All rights reserved.
  • 40. Twitter Copyright(c) Yusuke Yamamoto All rights reserved.
  • 41. Copyright(c) Yusuke Yamamoto All rights reserved.
  • 42. • Twitter development talk-ja http://bit.ly/tdt-ja• dev.twitter.com - Discussions https://dev.twitter.com/discussions Copyright(c) Yusuke Yamamoto All rights reserved.
  • 43. @twj_dev@twitterapi Copyright(c) Yusuke Yamamoto All rights reserved.
  • 44. Twitter API• http://amzn.to/iUeXjm Copyright(c) Yusuke Yamamoto All rights reserved. 44