Facebookã¢ããªã±ã¼ã·ã§ã³ãä½ãã(JavaScript Client Libraryç·¨)
æ¨æ¥ã¯æ±äº¬ã»å宿ã§è¡ããã"Facebook Developer Garage Tokyo"ã¨ããã¤ãã³ãã«åå ãã¦ããã
APIã®è©±ãæ¦è¦ã ãã§çµãã£ããMark Zuckerbergã(æ¼ã¾ã§æ¥æ¬ã«ããã®ã«!)帰å½ããå¾ã ã£ãããã¨ããã®ã¯æ®å¿µã ã£ãããéçºè
ãèªãã®ã¢ããªã±ã¼ã·ã§ã³ããã¢ããå ´ããããä½ãã豪è¯ãªæ©é£¯ã«ãããã¤ããã®ã§æºè¶³ã ãFacebook太ã£è
¹ãFacebook大好ã!
èªåã¯ã¾ã ãã¢ã§ãããããªãã®ã¯æã£ã¦ããªãã£ãã®ã ããOpenSocialæ代ã®ãã¤ã©ã«ã»ã©ã¼ãã³ã°åºç¤ãã¨ãã大風åæ·ãåºãã¦ãããã¨ããããè¿ããã¡ã«éçºã«ä¹ãåºããã¨ã¯ééããªããä»åã¯APIã®ä¸ã§ãã¾ã ã»ã¨ãã©è§£èª¬è¨äºãæ¸ããã¦ããªã"JavaScript Client Library"ãé¸ã³ãã¡ãã£ã¨ããç·´ç¿ãå§ãã¦ã¿ãããèªãã®å人ã®ãããã£ã¼ã«ç»åãå ¨ã¦åå¾ãããã¼ã¸ä¸ã«ãããã並ã¹ããã¨ããè¶ ã·ã³ãã«ãªãã®ã ã
<div id='foo'></div> <textarea style="width: 1000px; height: 300px;" id="_traceTextBox"></textarea> <script src="http://static.ak.facebook.com/js/api_lib/v0.3/FeatureLoader.js" type="text/javascript"> </script> <script type="text/javascript"> FB_RequireFeatures(["Api"], function(){ // ApiClientãªãã¸ã§ã¯ããä½ã var api = new FB.ApiClient('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', '/~yori/facebook_js/xd_receiver.htm', null); // ãã°ã¤ã³ api.requireLogin(function(exception) { // å人ä¸è¦§ãåã api.friends_get(null,function(result,exception){ var str=""; for(var i=0;i<result.length;i++){ // ç»åURLãåã api.users_getInfo(result[i],["uid","pic"],function(result2,exception){ // result2[0]["pic"]ãä½ãªã®ãããããªã人㯠Debug.dump(result2) ããã var img = result2[0]["pic"]; if(!img){ // ç»åãªãã£ãå ´å img = 'http://static.ak.fbcdn.net/pics/s_default.jpg'; } str=str+'<img src="' + img + '">'; document.getElementById('foo').innerHTML = str; // ãããã°æ å ± Debug.writeLine(result2[0]["uid"] +" " +result2[0]["pic"]); }); } }); }); }); </script>
âå®è¡ä¾ã¯ãããªæã(ã¢ã¶ã¤ã¯å
¥ã)ãä¸é¨ã®textareaã«ã¯ãããã°æ
å ±ãåºãã
Zipファイルでダウンロードできる文書ãè¦ãã¨ãããéãããã®JavaScriptç¨APIã®ããã¥ã¡ã³ãã¯é©ãã»ã©ãå å®ãã¦ããªãããä¸ã®ãµã³ãã«ã³ã¼ãä¸ã®api.users.getInfoã®ä½¿ãæ¹ã¯çµå±ãREST APIの使い方ã®ä¸ããä¼¼ãååã®ãã®ãè¦ã¤ãã¦ä½ã¨ãªãæ¨æ¸¬ãã¨ããæãã§åããããããµã¼ããµã¤ãã®ããã°ã©ã ãè¦ããªãããFacebookå¤ã®どんなサイトからでもAPIを呼べるãã¨ãã大ããªã¡ãªãããããã®ã«ãããã¯å¿ä½ç¡ããã¨ã ãããããhackããªããã¦ã¼ã¶(éçºè )ãèªãããã¥ã¡ã³ããæ¸ãã¤ã¤ä½åãããã°æ¥æ¬èªè¨³ããã¨ããæµãã¯ä»å¾èµ·ãããããããªãã
ã¾ããã³ã¼ã«ããã¯é¢æ°ã使ã£ãéåæå¦çã«æ £ãã¦ããªãã¨å®ç¨çãªããã°ã©ã ãä½ããã¨ããä¸ã§æ¸æããã¨ããå ´é¢ãæ³åã§ããããããªæã«ã¯amachangæ°ã触ãã¦ãã「非同期処理を同期処理のように書く方法」ã®ãä¸è©±ã«ãªããã¨ãããã¨æãã
æ¨æ¥ã®ã¤ãã³ãã¯ãå æã®MySpaceの勉強会ã¨ã¯è²ã ãªæå³ã§éã£ã¦ãããæ¥æ¬æ³äººããããã©ããã®éããªã®ã ãããä»åã®ä¼ç»ã¯(ä¸å¹´ãããåããèãã¦ããããã)æ¥æ¬äººã¦ã¼ã¶ã®æå¿ã«ãããã®ã ãä¼å ´ã®é°å²æ°ã¯神田さんが報じているéãããªã¼ããã³ã°ã«ã¯ããã©ã¼ãã¼éå£ãç»å ´ãã¦ããã