facebook api离线呼叫

时间:2012-07-17 06:50:50

标签: facebook-graph-api

我正在尝试使用facebok api。 为此,我创建了一个app-key。 并写了一个小程序。安装了apache并执行了该HTML文件。 Facebook徽标来了,但我无法从该程序中获取任何值。 如果我在facebook控制台上执行相同的程序,它可以工作并提供值。

是否无法在连接到互联网但使用私有IP的本地计算机上使用facebook api。我不想直接在我的服务器上工作。我希望在我的机器上离线测试一些东西,而不是部署代码......这是不可能的>

有没有更好的方法在facebook apis中使用java API打印frdslist

 <html>
<head>
  <title>My  Test Facebook Login Page</title>
</head>
<body>

  <div id="fb-root"></div>
  <script>
    window.fbAsyncInit = function() {
      FB.init({
        appId      : 'xxxxx', // App ID
        channelUrl : 'sample.com/backup', // Channel File
        status     : true, // check login status
        cookie     : true, // enable cookies to allow the server to access the session
        xfbml      : true  // parse XFBML
      });
    };                  
    // Load the SDK Asynchronously
    (function(d){
       var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
       if (d.getElementById(id)) {return;}
       js = d.createElement('script'); js.id = id; js.async = true;
       js.src = "//connect.facebook.net/en_US/all.js";         
       ref.parentNode.insertBefore(js, ref);
     }(document));


   FB.api('/me', function(response) {
alert("Name: "+ response.name + "\nFirst name: "+ response.first_name + "ID: "+response.id);
var img_link = "http://graph.facebook.com/"+response.id+"/picture"

});

     FB.api('/me/friends', { fields: 'name,id,location,birthday' }, function(result) {

})


  </script>


   <div class="fb-login-button" >Login with Facebook</div>


</body>

1 个答案:

答案 0 :(得分:0)

添加“read_friendlist”权限。