Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Evolution of API With Blogging

This talk is created by OpenOffice on Ubuntu. Including fonts are a little bit funny. Thank you for your interestings.

  • Login to see the comments

  • Be the first to like this

Evolution of API With Blogging

  1. 1. Evolution of API With Blogging YAPC::Asia Tokyo 2011 Takatsugu Shigeta YAPC::Asia Tokyo 2011 by Japan Perl Association is licensed under a Creative Commons Display - Non-Commercial 2.1 Japan License.
  2. 2. Before starting my talk... I deeply apologize for not realizing to write some code. I mentioned below in a description of my talk. “ I'll show you implementations of starman, Twiggy and TheSchwartz” But that didn't match my thoughts. I don't show you that in my talk.
  3. 4. Yeah... That's NOT stateless. I think that API should be stateless as REST. That pattern is asynchronized. I couldn't use that pattern in API.
  4. 5. Please don't throw a chair like Steve Ballmer or kazeburo!
  5. 6. Evolution of API With Blogging YAPC::Asia Tokyo 2011 Takatsugu Shigeta YAPC::Asia Tokyo 2011 by Japan Perl Association is licensed under a Creative Commons Display - Non-Commercial 2.1 Japan License.
  6. 7. Takatsugu Shigeta comewalk Some icons from google-api-perl-client A moderator of gearman/MogileFS/Perlbal mailing lists
  7. 8. Perl::Evolution
  8. 9. Movable Type 10 th Anniversary!
  9. 10. Let's talk about blogging API!
  10. 11. Contents 1 1983–1993 2 1994–2001 3 2001–2004 4 2004–present 5 References History Of Blogging
  11. 12. 1994-2001 The term "weblog" was coined by Jorn Barger on 17 Dec 1997. The short form, "blog," was coined by Peter Merholz in April or May 1999. LiveJournal was launched in Mar 1999. Blogger was launched in Aug 1999.
  12. 13. 2001-2004 Movable Type was released in Oct 2001. By 2001, blogging community increased rapidly.
  13. 14. 2004
  14. 15. 2011 YAPC::Asia Tokyo 2011 Evolution of API With Blogging
  15. 16. “ Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning.” - Albert Einstein 温故知新 - 孔子 Why?
  16. 17. Here we go!
  17. 21. Sample use Data::Dumper; use Net::Trackback::Client; use Net::Trackback::Ping; my $ping = Net::Trackback::Ping->new({ ping_url => '', url => '', title => 'Yet Another Trackback Test', description => 'This trackback which is generated by Net::Trackback.', }); my $client = Net::Trackback::Client->new; my $msg = $client->send_ping($ping); say Dumper($msg);
  18. 23. Sample use URI; use XML::Feed; my $uri = URI->new(''); my $parser = XML::Feed->parse($uri); say $parser->as_xml;
  19. 26. Sample use Data::Dumper; use XML::Feed; my $uri = ''; my @urls = XML::Feed->find_feeds($uri); say Dumper(@urls);
  20. 28. use URI; use XML::FOAF; my $uri = URI->new(''); my $foaf = XML::FOAF->new($uri); say $foaf->person->nick; Sample
  21. 29. Auto-Discovery <link rel=&quot; alternate &quot; type=&quot; application/atom+xml &quot; title=&quot;Atom&quot; href=&quot;; /> <link rel=&quot; alternate &quot; type=&quot; application/rss+xml &quot; title=&quot;RSS 1.0&quot; href=&quot;; /> <link rel=&quot; alternate &quot; type=&quot; application/rss+xml &quot; title=&quot;RSS 2.0&quot; href=&quot;; /> <link rel=&quot; openid.server &quot; href=&quot;; /> <link rel=&quot; EditURI &quot; type=&quot; application/rsd+xml &quot; title=&quot;RSD&quot; href=&quot;; /> <link rel=&quot; meta &quot; type=&quot; application/rdf+xml &quot; title=&quot; FOAF &quot; href=&quot;; />
  22. 30. Sample use Data::Dumper; use WWW::Blog::Metadata; # seealso: perldoc WWW::Blog::Metadata use WWW::Blog::Metadata::RSD; My $uri = ''; my $meta = WWW::Blog::Metadata->extract_from_uri($uri); say Dumper($meta->feeds); say Dumper($meta->rsd_uri);
  23. 31. Mobile Link Discovery <link rel=&quot; alternate &quot; media=&quot; handheld &quot; type=&quot;application/xhtml+xml&quot; href=&quot;; /> WWW::Blog::Metadata::MobileLinkDiscovery
  24. 33. XMLRPC use Data::Dumper; use RPC::XML::Client; my $client = RPC::XML::Client->new(''); my $request = RPC::XML::request->new( 'mt.supportedMethods', ); my $response = $client->send_request($request); say Dumper($response);
  25. 34. XMLRPC use Data::Dumper; use XMLRPC::Lite; my @result = XMLRPC::Lite ->proxy('') ->call('mt.supportedMethods') ->result; say Dumper(@result);
  26. 35. AtomPub use XML::Atom::Client; use XML::Atom::Entry; my $entry = XML::Atom::Entry->new; $entry->title('This entry is posted by Atom.'); $entry->content('Atom Atom Atom Atom'); my $api = XML::Atom::Client->new; $api->username('YourUserName'); $api->password('YourPassword'); my $PostURI = &quot;;; my $EditURI = $api->createEntry($PostURI, $entry);
  27. 36. WSSE my $nonce = $client->make_nonce; my $nonce_enc = encode_base64($nonce, ''); my $now = DateTime->now->iso8601 . 'Z'; my $digest = encode_base64(sha1($nonce . $now . ($client->password || '')), ''); $req->header(' X-WSSE ', sprintf qq( UsernameToken Username=&quot;%s&quot;, PasswordDigest=&quot;%s&quot;, Nonce=&quot;%s&quot;, Created=&quot;%s&quot; ), $client->username || '', $digest, $nonce_enc, $now); $req->header(' Authorization', 'WSSE profile=&quot;UsernameToken&quot; '); Code From XML::Atom::Client
  28. 37. RSD <?xml version=&quot;1.0&quot;?> <rsd version=&quot;1.0&quot; xmlns=&quot;;> <service> <engineName>TypePad</engineName> <engineLink></engineLink> <homePageLink></homePageLink> <apis> <api name=&quot;Atom&quot; preferred=&quot;false&quot; apiLink=&quot;; /> <api name=&quot;MetaWeblog&quot; preferred=&quot;true&quot; apiLink=&quot;; blogID=&quot;123&quot; /> <api name=&quot;Blogger&quot; preferred=&quot;false&quot; apiLink=&quot;; blogID=&quot;123&quot; /> <api name=&quot;MovableType&quot; preferred=&quot;false&quot; apiLink=&quot;; blogID=&quot;123&quot; /> </apis> </service> </rsd>
  29. 39. weblogUpdates Ping my $url = ''; my $req = HTTP::Request->new('POST', $url); $req->header('Content-Type' => 'text/xml'); my $text = <<XML; <?xml version=&quot;1.0&quot;?> <methodCall> <methodName></methodName> <params> <param><value>Foo::Bar</value></param> <param><value></value></param> </params> </methodCall> XML $req->content($text); my $ua = LWP::UserAgent->new; my $res = $ua->request($req);
  30. 40. OpenSearch <link rel=&quot;search&quot; type=&quot;application/opensearchdescription+xml&quot; href=&quot;; title=&quot;&quot; /> seealso WWW::OpenSearch
  31. 41. OpenID seealso Net::OpenID::Consumer
  32. 43. PubSubHubbub
  33. 44. PubSubHubbub Implementations Publisher Hub Subscriber ttp://
  34. 47. Trackback XMLRPC AtomPub Comment RSD weblogUpdates Ping Update Stream RSS Atom Activity Streams OpenSearch JSON PubSubHubbub OpenID OAuth WSSE FOAF oEmbed OPML Auto-Discovery Mobile Link Discovery microformats
  35. 48. Full view
  36. 49. Anyway, Are you enjoying YAPC::Asia?
  37. 52. This is very precious to me in YAPC::Asia Tokyo 2011! Did you have anything like this? You should talk with ROCK STARS!
  38. 53. Okay, back to my talk
  39. 54. Further Progress of API
  40. 55. JSON XML is still used as structured data/representation like HTML But response of API is moving to JSON.
  41. 56. With Document Your service should provide API explorer with API documentation
  42. 57. PATCH Method PATCH method allows us to apply partial modifications to a resource. RFC5789 PATCH Method for HTTP e.g.)
  43. 58. PATCH Method PATCH /gists/:id { &quot;description&quot;: &quot;the description for this gist&quot;, &quot;files&quot;: { &quot;file1.txt&quot;: { &quot;content&quot;: &quot;updated file contents&quot; }, &quot;old_name.txt&quot;: { &quot;filename&quot;: &quot;new_name.txt&quot;, &quot;content&quot;: &quot;modified contents&quot; }, &quot;new_file.txt&quot;: { &quot;content&quot;: &quot;a new file&quot; }, &quot;delete_this_file.txt&quot;: null } }
  44. 59. And Also ... REST (HTTP verbs, Resource, URI) Authentication (OAuth2) Rate Limiting
  45. 60. And more... Performance Tips Using gzip Working with partial response
  46. 61. Working With Partial Resource <ul><li> </li></ul><ul><li>200 OK </li></ul><ul><li>{ </li></ul><ul><li>&quot;kind&quot;: &quot;demo&quot;, </li></ul><ul><li>... </li></ul><ul><li>&quot;items&quot;: [ </li></ul><ul><li>{ </li></ul><ul><li>&quot;title&quot;: &quot;First title&quot;, </li></ul><ul><li>&quot;comment&quot;: &quot;First comment.&quot;, </li></ul><ul><li>&quot;characteristics&quot;: { </li></ul><ul><li>&quot;length&quot;: &quot;short&quot;, </li></ul><ul><li>&quot;accuracy&quot;: &quot;high&quot;, </li></ul><ul><li>&quot;followers&quot;: [&quot;Jo&quot;, &quot;Will&quot;], </li></ul><ul><li>}, </li></ul><ul><li>&quot;status&quot;: &quot;active&quot;, </li></ul><ul><li>... </li></ul><ul><li>}, </li></ul><ul><li>{ </li></ul><ul><li>&quot;title&quot;: &quot;Second title&quot;, </li></ul><ul><li>&quot;comment&quot;: &quot;Second comment.&quot;, </li></ul><ul><li>&quot;characteristics&quot;: { </li></ul><ul><li>&quot;length&quot;: &quot;long&quot;, </li></ul><ul><li>&quot;accuracy&quot;: &quot;medium&quot; </li></ul><ul><li>&quot;followers&quot;: [ ], </li></ul><ul><li>}, </li></ul><ul><li>&quot;status&quot;: &quot;pending&quot;, </li></ul><ul><li>... </li></ul><ul><li>}, </li></ul><ul><li>... </li></ul><ul><li>] </li></ul><ul><li>}} </li></ul><ul><li> fields=kind,items(title,characteristics/length) </li></ul><ul><li>200 OK </li></ul><ul><li>{ </li></ul><ul><li>&quot;kind&quot;: &quot;demo&quot;, </li></ul><ul><li>&quot;items&quot;: [ </li></ul><ul><li>{ </li></ul><ul><li>&quot;title&quot;: &quot;First title&quot;, </li></ul><ul><li>&quot;characteristics&quot;: { </li></ul><ul><li>&quot;length&quot;: &quot;short&quot; </li></ul><ul><li>} </li></ul><ul><li>}, </li></ul><ul><li>{ </li></ul><ul><li>&quot;title&quot;: &quot;Second title&quot;, </li></ul><ul><li>&quot;characteristics&quot;: { </li></ul><ul><li>&quot;length&quot;: &quot;long&quot; </li></ul><ul><li>} </li></ul><ul><li>}, </li></ul><ul><li>... </li></ul><ul><li>] </li></ul><ul><li>} </li></ul>
  47. 62. Think New Specifications
  48. 63. Think Data Portability These formats couldn't resolve to clone our data completely Movable Type Import/Export Format WordPress eXtended RSS Format Atom (Blogger) Import/Export
  49. 64. Import/Export Next Future? Camlistore is a way to store, sync, share, model and back up content
  50. 65. Semantic Web Which tools?
  51. 66. Blogging World Is Still Fun, Let's Hack Together!
  52. 67. Kudos To CPAN Authors! Data::Dumper Net::Trackback HTTP::Request Plagger LWP::UserAgent WWW::Search XML::Feed WWW::Blog::Metadata ( Web::Scraper) XML::Atom RPC::XML XMLRPC::Lite Especially, miyagawa++ Perl Modules I Mentioned
  53. 68. Finally, I would like to introduce a module for you
  54. 69. google-api-perl-client Google APIs Client Library for Perl
  55. 70. use URI; use Google::API::Client; my $client = Google::API::Client->new; My $service = $client->build('urlshortener', 'v1'); # Create a shortened URL by inserting the URL into the url collection. my $body = { 'longUrl' => '', }; my $res = $service->url->insert(body => $body)->execute; say 'short url is' . $res->{'id'};
  56. 71. I WAS VERY VERY EXCITED! Joe Gregorio mentioned the module in his Google+ stream. Brad Fitzpatrick directly emailed me that he can help me the module by code review or something like that.
  57. 72. I'll keep updating the module. And, if you are a programmer, also you can write some code. Right?
  58. 73. That's all, Thank you!
  59. 74. I'm using USB- booted Ubuntu VOTE ME!
  60. 75. THANK YOU!