2016-03-08 72 views
-1

我想获取来自Facebook好友的所有访问的数据的数据(仅姓名,生日,性别,现在是足以让我)。我的用户在App ID,我需要的只是公开的数据,所以我尝试了一些代码,但我只得到名称和Facebook的ID。 请提出我应该在我的代码中做什么?FQL查询来获取Facebook好友

function statusChangeCallback(response) { 
 
      console.log('statusChangeCallback'); 
 
      console.log(response); 
 
      if (response.status === 'connected') { 
 
       testAPI(); 
 
      } else if (response.status === 'not_authorized') { 
 
       document.getElementById('status').innerHTML = 'Please log ' + 'into this app.'; 
 
      } else { 
 
       document.getElementById('status').innerHTML = 'Please log ' + 'into Facebook.'; 
 
      } 
 
     } 
 
     function checkLoginState() { 
 
      FB.getLoginStatus(function(response) { 
 
       statusChangeCallback(response); 
 
      }); 
 
     } 
 
    
 
     window.fbAsyncInit = function() { 
 
      FB.init({ 
 
       appId : '155509608142654', 
 
       cookie : true, // enable cookies to allow the server to access 
 
       // the session 
 
       xfbml : true, // parse social plugins on this page 
 
       version : 'v2.5' // use version 2.2 
 
      }); 
 
      FB.getLoginStatus(function(response) { 
 
       statusChangeCallback(response); 
 
      }); 
 
    
 
     }; 
 
     
 
     
 
     
 
    
 
     // Load the SDK asynchronously 
 
     (function(d, s, id) { 
 
      var js, fjs = d.getElementsByTagName(s)[0]; 
 
      if (d.getElementById(id)) 
 
       return; 
 
      js = d.createElement(s); 
 
      js.id = id; 
 
      js.src = "//connect.facebook.net/en_US/sdk.js"; 
 
      fjs.parentNode.insertBefore(js, fjs); 
 
     } 
 
     (document, 'script', 'facebook-jssdk')); 
 
     function testAPI() { 
 
      console.log('Welcome! Fetching your information.... '); 
 
      FB.api('/me?fields=name,friends{age_range,birthday,gender}', function(response) { 
 
           console.log(response); 
 
           document.getElementById('userDetails').innerHTML = 'Thanks for logging in, ' + response.name + ' below are your information!' + '<br><b>Name:</b>' + response.name +'<br><b>frnd:</b>' + response.friendgender + '<br><b>frnd list:</b>' + response.friendlists + '<br><b>Facebook link:</b>' + response.link + '<br><b>Local:</b>' + response.location + '<br><b>Facebook Id:</b>' + response.id; 
 
        

>

+0

首先,就是_not_ FQL,但一个正常的图形API调用。而且你不能通过API获取任何你喜欢的关于朋友的信息,大部分内容都需要朋友的许可。 – CBroe

回答

0

你只能得到谁授权你的应用程序也与所需权限好友资料。朋友权限已被删除,出于隐私原因:https://developers.facebook.com/docs/apps/changelog

例如,朋友需要授权您的应用程序的user_birthday权限,如果你想获得他们的生日。

+0

我已经这样做了,我的应用程序是由我的朋友授权的。 – Abhi

+0

和他们有一个生日,他们授权与许可user_birthday?通过您的API调用,为我工作得很好。 – luschn

+0

顺便说一句,我不得到任何AGE_RANGE,我认为that's根本不可能的。 – luschn