1

iframeキャンバスアプリケーション用にJavaScriptSDKを非同期で読み込んでいます。

fbmlが非推奨になり、段階的に廃止されることは承知していますが、xfbmlはまだ問題ありませんか?

それでもfb:nameを使用できますか?<fb:name uid="2901279">

たとえば、ユーザーの100人の友達の名前を印刷するより良い方法はありますか?

4

2 に答える 2

2

Graph APIの使用を開始する必要があります。これは、開始するための簡単なです。

<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<title>Facebook Javascript SDK</title>
</head>
<body>
    <div><fb:login-button perms=""></fb:login-button></div>

    <div id="friends"></div>


    <div id="fb-root"></div>
    <script>
      window.fbAsyncInit = function() {
        FB.init({
          appId   : 'APP_ID',
          cookie  : true,
          status  : true,
          xfbml   : true 
        });

        FB.Event.subscribe('auth.login', function(response) {
          window.location.reload();
        });

        FB.api('/me/friends',function(resp) {
            if(resp && resp.data.length) {
                var html = '<ul>';
                for(var i=0; i<resp.data.length; i++) {
                    html += '<li><img src="http://graph.facebook.com/' + resp.data[i].id + '/picture?type=small" />' + resp.data[i].name + '</li>';
                }
                html += '</ul>';
                document.getElementById('friends').innerHTML = html;
            }
        });
      };

      (function() {
        var e = document.createElement('script');
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
      }());
    </script>
</body>
</html>

アプリケーションIDに置き換えるだけで、準備完了です。

于 2011-05-14T23:24:58.007 に答える
1

あなたは正しいです、あなたはおそらくもう使うべきではありませんfbmlが、「ソーシャルプラグイン」からのすべてのマークアップはそれでも奨励されます(すなわちlike button)。

非推奨であるかどうかに関係なく、アプリのレイアウトを完全に制御することをお勧めします。代わりに<fb:name...タグを使用して、「http://graph.facebook.com/UID/friends」からすべての友達リストを取得し、結果を解析できますJSON。(PHP-SDKの場合:) $fb->api("/me/friends");

于 2011-05-14T22:43:17.737 に答える