1

我正在使用Facebook Javascript SDK登錄我的網站並捕獲有關用戶朋友的信息。如何將用戶朋友連接的Facebook圖表api響應存儲到變量或數組以便稍後使用javascript使用

下面的代碼塊檢查用戶是否登錄,然後在數組中捕獲用戶朋友的詳細信息。

我現在不明白的是如果數據存儲在數組存在?我如何將朋友數據添加到數組中,以後可以傳遞給我的數據庫?我怎樣才能使用Chrome檢查器再次查看數據?我會做一個控制檯日誌來查看對象嗎?

FB.getLoginStatus(function(response) { 
    if (response.status === 'connected') { 
    FB.api('/me/friends', function(response){ 
     if (response && response.data){ 
     console.log('Success', response); 



     } else { 
     console.log('Something goes wrong', response); 
     } 
    }); 
    } 
}); 

enter image description here

+0

您可以使用['jQuery.data()'](https://api.jquery.com/jQuery.data/解決了這個) –

+0

謝謝,你介意解釋我將如何使用它?從上面我不知道什麼名字解析? – Dano007

回答

0

我用

FB.getLoginStatus(function (response) { 
    if (response.status === 'connected') { 
    FB.api('/me/friends', function(response){ 
     if (response && response.data){ 
     var contact = Parse.Object.extend("_User"); 
     var fbdata=response.data; 
     var divTarget=document.getElementById("friends-list-container"); 
     for (var friendIndex=0; friendIndex<fbdata.length; friendIndex++) 
    {  var divContainer = document.createElement("div"); 
      divContainer.innerHTML="<b>" + fbdata[friendIndex].name + "</b>"; 
      divTarget.appendChild(divContainer); 
    } 
相關問題