2011-05-14 4 views

답변

2

는 현재 빠른 가 얻을 수 예를 들어 작업의, 그래프 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로 교체하고 당신은 갈 수 있습니다!

1

맞습니다. fbml을 더 이상 사용하지 않아야하지만 "소셜 플러그인"의 모든 마크 업은 계속 권장됩니다 (즉, like button).

아무리 중요하지 않든 그렇지 않든, 내 레이아웃의 모든 컨트롤을 선호합니다 .- 대신 <fb:name... 태그를 사용하면 "http://graph.facebook.com/UID/friends"에서 모든 친구 목록을 얻을 수 있습니다. 구문 분석 결과는 JSON입니다. (PHP-SDK : $fb->api("/me/friends");).

관련 문제