flickr open api mashup
DESCRIPTION
Flickr Open Api MashupTRANSCRIPT
flickr Open API & Mash-up
2008. 05. 26
Yahoo! Korea , Jinho Jung
• flickr #$
• API Key & NSID
• DEMO– NSID% &'( )* +,
– Photo ID- )* ./ 0123
– )'4 ./ 0123
• Flickr API Explorer
• Flickr Feeds & Format
• DEMO– HTML Badge 563
• 78 & API Signature
!"
• flickr =>??
• flickr &' @ /AB??
• Open API =>??
• Open API CD EF ?
9: ;<
flickr
• GH7 )* IJ K LM
–)* N-O
–)*IJ
–&P,LM
–QR
• ST( 563
–Open API % &'
–7U, )*V
–WH&OX DVD, YZ
About flickr
moo.com
• Flickr [\
–]^ 12,000 $ &_Q `ab (2.6TB)
–cc 2005de &_Q N-O
– fgh ! "#$ &_Q
• \. : Free vs. Pro
– Free! Space : 200M / month
! Set : 3$
– Pro!Unlimited
!Gift!
flickr [\
• Set –i. jC kle )* mn
– op&q rstu, ‘v] wxu
• Collection– Set(yz S{ Collection)e mn
–0|, }R(2007, 2006)
• )*IJ
– Collection K >~% 5Oz �
–c� �� ��, �( �E yz
�9 �V
)*IJ
�~, &P
• �~ K ��
–�~ - )* �� �� �z ��Q
–�� - &_Q =�� p3z �
• &P
–��, 0|
– '&P )*' �&Q
N-O
• Flickr Uploadr (PC, Mac)
• iPhoto, Aperture
• Windows XP plugin
• Upload Page
• HTML, CSS, XML & XPath
• JS & DOM , AJAX , JSON,
• Web Server & HTTP , Database
• PHP , Perl, Regular Expression
• REST, SOAP, XML-RPC, Curl
MashUp� �( 3�
Flickr Open API
• activity
• auth
• blogs
• contacts
• favorites
• groups
• interestingness
• people
• photos
• photos.geo
• photos.licenses
• photos.notes
• photos.transform
• photos.upload
• photosets
• photosets.comments
• prefs
• reflection
• tags
• test
• urls
• NSID – Network Service ID
–�M( User =&� �
– EX) 81559972@N00 ( = phploveme)
–���� �E 0�, NSIDz �E 0�
• API Key
–¡&¢ ?£ � )'¤z ID
–¥N' , a¥N'($¦')
– API Key §£
! http://www.flickr.com/services/api/keys/
NSID & API Key
API Key §£
• Charter Encoding : UTF-8
• Request Format
–REST, SOAP, XML-RPC
• REST API Endpoint
– http://api.flickr.com/services/rest/
• API key ª Method % &'
API )' ¨©
[ DEMO ] NSID% "&' () *+
• flickr.photos.search– Endpoint : http://api.flickr.com/services/rest/
–method : flickr.photos.search
– user_id : 81559972@N00 ( phploveme NSID)
– per_page : 5!Default : 100 , MAX: 500
– api_key : MY_API_KEY
• Request URL– http://api.flickr.com/services/rest/?
method=flickr.photos.search&user_id=81559972@N00&per_page=5&api_key=25f136aee2f23291097789fb5dc13931
DEMO : NSID% &'( )* +,
<?xml version="1.0" encoding="utf-8" ?>
- <rsp stat="ok">
- <photos page="1" pages="236" perpage="5" total="1180">
<photo id="565367310" owner="81559972@N00" secret="59ddfb1d5f" server="1037" farm="2" title="�« ¬" ispublic="1" isfriend="0" isfamily="0" />
<photo id="565759301" owner="81559972@N00" secret="8ae60ad3a4" server="1104" farm="2" title="®¯) R°±" ispublic="1" isfriend="0" isfamily="0" />
<photo id="565367234" owner="81559972@N00" secret="b749f597d5" server="1161" farm="2" title=";²³ :´" ispublic="1" isfriend="0" isfamily="0" />
<photo id="565759217" owner="81559972@N00" secret="9030c43e55" server="1410" farm="2" title="£/J" ispublic="1" isfriend="0" isfamily="0" />
<photo id="565759175" owner="81559972@N00" secret="273f96008d" server="1424" farm="2" title="Cj _-Lµ" ispublic="1" isfriend="0" isfamily="0" />
</photos>
</rsp>
• Result
DEMO : NSID% &'( )* +,
• rsp : ¶· ¸¹
– stat="ok"
• photos : +, ¸¹ ?º
– page="1" »¼ �&Q
– pages="236" ½Q¾ �&Q
– perpage="5" �&Q^ &_Q ¿
– total="1180" +,À &_Q
• photo : +,¸¹ )*
– id="565367310" �M( Photo ID
– owner="81559972@N00" ÁÂ4 NSID
– secret="59ddfb1d5f" Image Server URL �'
– server="1037" Image Server URL �'
– farm="2" Image Server URL �'
– title="�« ¬" CÃ
DEMO : NSID% &'( )* +,
[ DEMO ] Photo ID,
() -. /012
• flickr.photos.getInfo
– Endpoint : http://api.flickr.com/services/rest/
– method : flickr.photos.getInfo
– photo_id : 445533638
– api_key : MY_API_KEY
• Photo URL
– http://www.flickr.com/photos/phploveme/445533638/
• Request URL– http://api.flickr.com/services/rest/?
api_key=25f136aee2f23291097789fb5dc13931&method=flickr.ph
otos.getInfo&photo_id=445533638
DEMO : Photo ID- )* ./ 0123
<?xml version="1.0" encoding="utf-8" ?>
- <rsp stat="ok">
- <photo id="445533638" secret="b7ce85e4c8" server="224" farm="1" dateuploaded="1175649087" isfavorite="0" license="0" rotation="0" originalsecret="61c37df859" originalformat="jpg">
<owner nsid="81559972@N00" username="phploveme" realname="Jinho Jung" location="South Korea" />
<title>aG Ä �ÅÆO ÇE</title>
<description />
<visibility ispublic="1" isfriend="0" isfamily="0" />
<dates posted="1175649087" taken="2004-02-21 19:33:07" takengranularity="0" lastupdate="1182170636" />
<editability cancomment="0" canaddmeta="0" />
<comments>9</comments>
<notes />
- <tags>
<tag id="1281997-445533638-187219" author="81559972@N00" raw="everland" machine_tag="0">everland</tag>
<tag id="1281997-445533638-1213" author="81559972@N00" raw="night" machine_tag="0">night</tag>
<tag id="1281997-445533638-373261" author="81559972@N00" raw="�ÅÆO" machine_tag="0">�ÅÆO</tag>
</tags>
- <urls>
<url type="photopage">http://www.flickr.com/photos/phploveme/445533638/</url>
</urls>
</photo>
</rsp>
• Result
DEMO : Photo ID- )* ./ 0123
• Photo
– username="phploveme"
– realname="Jinho Jung"
– location="South Korea"
– title : aG Ä �ÅÆO ÇE
– dates
! posted="1175649087" ÁÂc UNIX Timestamp
! taken="2004-02-21 19:33:07" ÈÉc
– Comments : 9
• Urls
– http://www.flickr.com/photos/phploveme/445533638/
DEMO : Photo ID- )* ./ 0123
[ DEMO ] NSID% "&'
(&3 -. 42
• flickr.people.getInfo
– Endpoint : http://api.flickr.com/services/rest/
–method : flickr.people.getInfo
– user_id : 81559972@N00 (phploveme)
– api_key : MY_API_KEY
• Request URL– http://api.flickr.com/services/rest/?
api_key=25f136aee2f23291097789fb5dc13931&method=flickr.people.getInfo&user_id=81559972@N00
DEMO : )'4 ./ 0123
<?xml version="1.0" encoding="utf-8" ?>
- <rsp stat="ok">
- <person id="81559972@N00" nsid="81559972@N00" isadmin="0" ispro="1" iconserver="184" iconfarm="1">
<username>phploveme</username>
<realname>Jinho Jung</realname>
<mbox_sha1sum>7fe046668354e5f10a223088c8d24708634e6815 </mbox_sha1sum>
<location>South Korea</location>
<photosurl>http://www.flickr.com/photos/phploveme/</photosurl>
<profileurl>http://www.flickr.com/people/phploveme/</profileurl>
<mobileurl>http://m.flickr.com/photostream.gne?id=1281997</mobileurl>
- <photos>
<firstdatetaken>2003-10-01 22:31:02</firstdatetaken>
<firstdate>1175649047</firstdate>
<count>1153</count>
</photos>
</person>
</rsp>
• Result
DEMO : )'4 ./ 0123
• API test % �( ÊY �J( R�
–Ê$ �¿
–¶· ËC
– URL Ì
• API <` Cc ¤:� �Í
– http://www.flickr.com/services/api/flickr.people.getInfo.htm
567 : Flickr API Explorer
Flickr API Explorer
• Ðc( �#Oz (Ñ5 ÒÓ
• �#O ÒÓÔ�Ô0�¤Õ Ö� ./% 01×
• Ø?( ¡&¢% ?£¤Q Ùn
• ¡&¢ ÚÛ
Î¹Ï API &'
• )' 0�( ÜO ÃÂ
– http://www.flickr.com/services/feeds/
• ÝÞ� N-O À mß )*:
– http://api.flickr.com/services/feeds/photos_public.gne
• i. )'4e L$À )*:
– http://api.flickr.com/services/feeds/photos_public.gne?id=USER-NSID
• �à )* mn
– http://api.flickr.com/services/feeds/groups_pool.gne?id=GROUP-NSID
Flickr Feeds
• rss2 : RSS 2.0
• atom : Atom 1.0
• rss_091 : RSS 0.91
• rss_092 , rss : RSS 0.92
• rss_100 , rdf : RSS 1.0
• rss_200_enc : RSS 2.0 with enclosures
• 3á
– php, php_serial,
– csv, json, sql, yaml, cdf
Feeds Format
[ DEMO ] HTML Badge 892
Flickr HTML Badge New HTML Badge
• http://www.flickr.com/badge.gne
• âã ä* HTML Badge
DEMO : HTML Badge 563
<?php $feed = array( 'title'=> "phplovemeåe )*",
'url' => http://www.flickr.com/photos/phploveme/", 'description' => "", 'pub_date' => "1182188262", …
• php feeds &'
• $feed : ¸¹�e PHP Code Block
• http://api.flickr.com/services/feeds/photos_public.gne?id=81559972@N00&format=php
• ¸¹
DEMO : HTML Badge 563
• <html>
• <head>
• <title>Flickr Mashups: New Badge </title>
• <link href="../css/main.css" rel="stylesheet" type="text/css" />
• <link href="../css/badge.css" rel="stylesheet" type="text/css" />
• </head>
• <body>
• <?php include('./badge.php') ?>
• </body>
• </html>
Index.html
• include("http://api.flickr.com/services/feeds/photos_public.gne?id=81559972@N00&format=php");
• …
• $str .= '<p class="badge-title"> <a href="' . $feed['url'] . '">' .$feed['title'] . '</a></p>';
• $items = $feed['items'];
• for ($i = 0; $i < count($items); $i++)
• {
• if (preg_match('/(http:\/\/farm[0-9].static.flickr.com\/\d+\/\d+_[0-9a-z]+)_m\.jpg/',$items[$i]['description'],$result))
• {
• $image = $result[1] . '_s.jpg';
• $str .= '<li class="badge-item"><a href="'.$items[$i]['url'].'">
• <img src="'.$image.'" alt="'.$items[$i]['title'].'" /></a></li>';
• }
• }
• …
• echo($str);
badge.php : $feed
�_) ; æ s 3
sq )çè 75 x 75
t é�c êë 100
s D� s3 êë 240
m k9 s3 êë 500
o µì &_Q µì
• http://flickr.com/photo_zoom.gne?id=565367020&size=sq
Flickr Image Size
• 78
–aL$- ;.À )*
–N-O N-O,¿., íC
• aL$ )*
– http://flickr.com/photos/phploveme/560185670/
78 : Authentication
• Mashup 78 je)î
–Mashup �`z ID/PW % ïQ ½H!
–ðJñ )&~�`5 ID/PW -�7
–Mashup � �(5 òw ózS
–)'4z �( ¿ô� Q./íC
78 : Authentication
UserUser1. Redirect
3rd Party Mashup
3. Authentication :
Read, Write, Delete
4. Permission
2. Log in
X
Mashup 78
• Mashup� 78& Ø?( EY
=� URL- Redirect �õS
– http://flickr.com/services/auth/?api_key=API-KEY&perms=PERMS&api_sig=API-SIG
• Ê$ �¿
– api_key : 78ö
– perms : read , write , delete
– api_sig : �#O ÒÓ' `æ(signature)
78 : Mashup � �( òw¤3
• API ö 78 ;.
API Signature 563
• api_sig ö Ì ¨©
– md5(secret+api_key+api_val+perms+ perms_val)
• ËC
– Secret : 1d0c5d654af2d1e9
– api_key : 25f136aee2f23291097789fb5dc13931
– perms: read
– api_sig
=md5(1d0c5d654af2d1e9api_key25f136aee2f23291
097789fb5dc13931permsread)=
API Signature 563
01b108f97ffaa4882ee2a93ab90ffff4
• 78 URL
– http://flickr.com/services/auth/?api_key=25f136aee2f23291097789fb5dc13931&perms=read&api_sig=01b108f97ffaa4882ee2a93ab90ffff4
Mashup 78
CallBackURL
• )'k7 ÷ò Mashup �(
– http://www.flickr.com/services/auth/list.gne
Mashup 78 ¥�
[ DEMO ]Flickr Badge Wizard
http://lovesera.com/tt/253
• Flickr Services API <`
– http://www.flickr.com/services/api/
• Flickr API �à
– http://www.flickr.com/groups/api/
• Flickr API Korea
– http://www.flickr.com/groups/apikr/
• Mashup Camp :;
– http://lovesera.com/tt/253
• FD’s flickr Toys
– http://bighugelabs.com/flickr/
URLs
Thanks
flickr
BLOG : lovesera.com