Evolution of API With Blogging
Upcoming SlideShare
Loading in...5
×
 

Evolution of API With Blogging

on

  • 1,592 views

http://yapcasia.org/2011/talk/48

http://yapcasia.org/2011/talk/48

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

Statistics

Views

Total Views
1,592
Views on SlideShare
1,293
Embed Views
299

Actions

Likes
0
Downloads
3
Comments
0

9 Embeds 299

http://blog.comewalk.com 267
http://yapcasia.org 18
http://comewalk.typepad.com 5
http://dogfood.typepad.jp 3
http://webcache.googleusercontent.com 2
http://a0.twimg.com 1
http://feeds.feedburner.com 1
http://tshigeta.typepad.jp.tshigeta.dev.sixapart.jp 1
http://www.typepad.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Evolution of API With Blogging Evolution of API With Blogging Presentation Transcript

  • 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.
  • 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.
  •  
  • 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.
  • Please don't throw a chair like Steve Ballmer or kazeburo!
  • 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.
  • Takatsugu Shigeta comewalk Some icons from http://icondock.com/ google-api-perl-client A moderator of gearman/MogileFS/Perlbal mailing lists http://blog.comewalk.com
  • Perl::Evolution
  • Movable Type 10 th Anniversary!
  • Let's talk about blogging API!
  • Contents 1 1983–1993 2 1994–2001 3 2001–2004 4 2004–present 5 References http://en.wikipedia.org/wiki/History_of_blogging History Of Blogging
  • 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. http://en.wikipedia.org/wiki/History_of_blogging
  • 2001-2004 Movable Type was released in Oct 2001. By 2001, blogging community increased rapidly. http://en.wikipedia.org/wiki/History_of_blogging
  • 2004
  • 2011 YAPC::Asia Tokyo 2011 Evolution of API With Blogging
  • “ Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning.” - Albert Einstein 温故知新 - 孔子 Why?
  • Here we go!
  •  
  •  
  •  
  • Sample use Data::Dumper; use Net::Trackback::Client; use Net::Trackback::Ping; my $ping = Net::Trackback::Ping->new({ ping_url => 'http://example.com/trackback/1234/5678', url => 'http://example.com/blog/2011/10/post-1.html', 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);
  •  
  • Sample use URI; use XML::Feed; my $uri = URI->new('http://example.com/rss.xml'); my $parser = XML::Feed->parse($uri); say $parser->as_xml;
  •  
  •  
  • Sample use Data::Dumper; use XML::Feed; my $uri = 'http://example.com'; my @urls = XML::Feed->find_feeds($uri); say Dumper(@urls);
  •  
  • use URI; use XML::FOAF; my $uri = URI->new('http://example.com'); my $foaf = XML::FOAF->new($uri); say $foaf->person->nick; Sample
  • Auto-Discovery <link rel=&quot; alternate &quot; type=&quot; application/atom+xml &quot; title=&quot;Atom&quot; href=&quot;http://example.com/atom.xml&quot; /> <link rel=&quot; alternate &quot; type=&quot; application/rss+xml &quot; title=&quot;RSS 1.0&quot; href=&quot;http://example.com/index.rdf&quot; /> <link rel=&quot; alternate &quot; type=&quot; application/rss+xml &quot; title=&quot;RSS 2.0&quot; href=&quot;http://example.com/rss.xml&quot; /> <link rel=&quot; openid.server &quot; href=&quot;http://example.com/openid/server&quot; /> <link rel=&quot; EditURI &quot; type=&quot; application/rsd+xml &quot; title=&quot;RSD&quot; href=&quot;http://example.com/rsd/123&quot; /> <link rel=&quot; meta &quot; type=&quot; application/rdf+xml &quot; title=&quot; FOAF &quot; href=&quot;http://example.com/foaf.rdf&quot; />
  • Sample use Data::Dumper; use WWW::Blog::Metadata; # seealso: perldoc WWW::Blog::Metadata use WWW::Blog::Metadata::RSD; My $uri = 'http://example.com'; my $meta = WWW::Blog::Metadata->extract_from_uri($uri); say Dumper($meta->feeds); say Dumper($meta->rsd_uri);
  • Mobile Link Discovery <link rel=&quot; alternate &quot; media=&quot; handheld &quot; type=&quot;application/xhtml+xml&quot; href=&quot;http://example.com/mobile&quot; /> WWW::Blog::Metadata::MobileLinkDiscovery http://www.sixapart.jp/docs/tech/mobile_link_discovery_en.html
  •  
  • XMLRPC use Data::Dumper; use RPC::XML::Client; my $client = RPC::XML::Client->new('http://www.typepad.jp/t/api'); my $request = RPC::XML::request->new( 'mt.supportedMethods', ); my $response = $client->send_request($request); say Dumper($response);
  • XMLRPC use Data::Dumper; use XMLRPC::Lite; my @result = XMLRPC::Lite ->proxy('http://www.typepad.com/t/api') ->call('mt.supportedMethods') ->result; say Dumper(@result);
  • 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;http://example.com/atom/weblog/blog_id=YourBlogID&quot;; my $EditURI = $api->createEntry($PostURI, $entry);
  • 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
  • RSD <?xml version=&quot;1.0&quot;?> <rsd version=&quot;1.0&quot; xmlns=&quot;http://archipelago.phrasewise.com/rsd&quot;> <service> <engineName>TypePad</engineName> <engineLink>http://www.typepad.com/</engineLink> <homePageLink>http://blog.comewalk.com/</homePageLink> <apis> <api name=&quot;Atom&quot; preferred=&quot;false&quot; apiLink=&quot;http://www.typepad.com/services/atom/svc=blogs/blog_id=123&quot; /> <api name=&quot;MetaWeblog&quot; preferred=&quot;true&quot; apiLink=&quot;http://www.typepad.com/services/xmlrpc&quot; blogID=&quot;123&quot; /> <api name=&quot;Blogger&quot; preferred=&quot;false&quot; apiLink=&quot;http://www.typepad.com/services/xmlrpc&quot; blogID=&quot;123&quot; /> <api name=&quot;MovableType&quot; preferred=&quot;false&quot; apiLink=&quot;http://www.typepad.com/services/xmlrpc&quot; blogID=&quot;123&quot; /> </apis> </service> </rsd>
  •  
  • weblogUpdates Ping my $url = 'http://rpc.weblogs.com/RPC2'; my $req = HTTP::Request->new('POST', $url); $req->header('Content-Type' => 'text/xml'); my $text = <<XML; <?xml version=&quot;1.0&quot;?> <methodCall> <methodName>weblogUpdates.ping</methodName> <params> <param><value>Foo::Bar</value></param> <param><value>http://example.com</value></param> </params> </methodCall> XML $req->content($text); my $ua = LWP::UserAgent->new; my $res = $ua->request($req);
  • OpenSearch <link rel=&quot;search&quot; type=&quot;application/opensearchdescription+xml&quot; href=&quot;http://example.com/opensearch/search.xml&quot; title=&quot;&quot; /> seealso WWW::OpenSearch
  • OpenID seealso Net::OpenID::Consumer
  •  
  • PubSubHubbub http://code.google.com/p/pubsubhubbub/
  • PubSubHubbub Implementations Publisher http://pubsubhubbub.googlecode.com/svn/trunk/ Hub http://pubsubhubbub.appspot.com/ Subscriber ttp://d.hatena.ne.jp/tokuhirom/20100307/push
  •  
  •  
  • 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
  • Full view
  • Anyway, Are you enjoying YAPC::Asia?
  •  
  •  
  • This is very precious to me in YAPC::Asia Tokyo 2011! Did you have anything like this? You should talk with ROCK STARS!
  • Okay, back to my talk
  • Further Progress of API
  • JSON XML is still used as structured data/representation like HTML But response of API is moving to JSON.
  • With Document Your service should provide API explorer with API documentation http://explorer.metacpan.org/ http://code.google.com/apis/explorer/ https://developer.foursquare.com/docs/explore.html
  • PATCH Method PATCH method allows us to apply partial modifications to a resource. RFC5789 PATCH Method for HTTP http://www.ietf.org/rfc/rfc5789.txt e.g.) http://developer.github.com/v3/#http-verbs
  • 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 } } http://developer.github.com/v3/gists/
  • And Also ... REST (HTTP verbs, Resource, URI) Authentication (OAuth2) Rate Limiting
  • And more... Performance Tips Using gzip Working with partial response http://code.google.com/apis/discovery/v1/performance.html
  • Working With Partial Resource
    • https://www.googleapis.com/demo/v1?key=YOUR-API-KEY
    • 200 OK
    • {
    • &quot;kind&quot;: &quot;demo&quot;,
    • ...
    • &quot;items&quot;: [
    • {
    • &quot;title&quot;: &quot;First title&quot;,
    • &quot;comment&quot;: &quot;First comment.&quot;,
    • &quot;characteristics&quot;: {
    • &quot;length&quot;: &quot;short&quot;,
    • &quot;accuracy&quot;: &quot;high&quot;,
    • &quot;followers&quot;: [&quot;Jo&quot;, &quot;Will&quot;],
    • },
    • &quot;status&quot;: &quot;active&quot;,
    • ...
    • },
    • {
    • &quot;title&quot;: &quot;Second title&quot;,
    • &quot;comment&quot;: &quot;Second comment.&quot;,
    • &quot;characteristics&quot;: {
    • &quot;length&quot;: &quot;long&quot;,
    • &quot;accuracy&quot;: &quot;medium&quot;
    • &quot;followers&quot;: [ ],
    • },
    • &quot;status&quot;: &quot;pending&quot;,
    • ...
    • },
    • ...
    • ]
    • }}
    • https://www.googleapis.com/demo/v1?key=YOUR-API-KEY& fields=kind,items(title,characteristics/length)
    • 200 OK
    • {
    • &quot;kind&quot;: &quot;demo&quot;,
    • &quot;items&quot;: [
    • {
    • &quot;title&quot;: &quot;First title&quot;,
    • &quot;characteristics&quot;: {
    • &quot;length&quot;: &quot;short&quot;
    • }
    • },
    • {
    • &quot;title&quot;: &quot;Second title&quot;,
    • &quot;characteristics&quot;: {
    • &quot;length&quot;: &quot;long&quot;
    • }
    • },
    • ...
    • ]
    • }
  • Think New Specifications
  • 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
  • Import/Export Next Future? Camlistore is a way to store, sync, share, model and back up content http://camlistore.org/
  • Semantic Web Which tools?
  • Blogging World Is Still Fun, Let's Hack Together!
  • 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
  • Finally, I would like to introduce a module for you
  • google-api-perl-client Google APIs Client Library for Perl http://code.google.com/p/google-api-perl-client/ https://github.com/comewalk/google-api-perl-client/
  • 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' => 'http://code.google.com/apis/urlshortener/', }; my $res = $service->url->insert(body => $body)->execute; say 'short url is' . $res->{'id'};
  • 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.
  • I'll keep updating the module. And, if you are a programmer, also you can write some code. Right?
  • That's all, Thank you!
  • I'm using USB- booted Ubuntu VOTE ME!
  • THANK YOU!