2016-11-14 53 views
0

我试图让我的朋友在facebook上使用图形API。但是,我的ID在桌面和手机中显示的都不一样。我正在研究Ionic 2,我需要让我的朋友使用Android手机。通过使用由桌面生成的ID,我得到一些朋友。但是,通过手机生成的ID,朋友列表是空的。如何解决这个问题?在一个设备中返回的ID是否与其他设备不匹配?

这里是我的代码

fbGetDetails() { 
    Facebook.getLoginStatus().then(response => { 
     if(response.status == "connected"){ 
      Facebook.api("/" + response.authResponse.userID + "/friends", []).then(res => { 
       alert("Total friends = " + res.summary.total_count); 
       alert(response.authResponse.userID); 
       if(res.data.length){ 
        alert("Authorized friends = " + res.data.length); 
        for(var i=0; i<res.data.length; i++){ 
         this.friends[i] = res.data[i]; 
         // Facebook.api("/" + this.friends[i].id + "/picture", []).then(resp => { 
         // this.friends[i].picture = resp.data.url; 
         // }) 
        } 
       } else{ 
        alert("None of your frieds are using this app"); 
       } 
      }); 
     } 
    }) 
} 

在上面的代码authResponse.userID将生成的ID。实际上,我登录桌面并检查图形API浏览器。它展示了我的一位朋友。 enter image description here

但是,即使我在上面的代码"/me/friends"而不是"/" + response.authResponse.userID + "/friends"也是我在我的手机越来越没有朋友提及。

回答

0

您可能正在使用不同的应用程序的桌面和离子。 ID是“应用程序范围”,因此您可以为每个应用程序获得不同的ID。此外,您也只能通过user_friends权限获得授权您的应用的朋友。

顺便说一下,你可以使用/me/friends而不是/user-id/friends

相关问题