2011-06-27 64 views
0

它可能聽起來有點有趣,但我不知道如何獲取從使用JavaScript的Facebook FQL查詢中獲取的數據。我在網上查找,只有關於如何運行查詢的教程,但現在如何獲取數據。如何打印/獲取從FQL查詢中獲取的數據?

所以這裏是我的代碼有:

  if (response.session) { 
     FB.api({ 
     method: "fql.query", 
     query: "SELECT name,email FROM user WHERE uid = " + response.session.uid 
     }); 
              customar_formcode="'.$formcode.'"; 
              customar_formcode=customar_formcode.replace("{email}", USER EMAIL FROM THE FQL); 
              customar_formcode=customar_formcode.replace("{name}", USER NAME FROM THE FQL); 
              document.getElementById('form').submit(); 

因此,如何將用戶的姓名和電子郵件,其中 「USER EMAIL FROM THE FQL」 和 「用戶的名字從FQL」。

謝謝。

回答

1

你必須定義回調函數:

FB.api({ 
     method: "fql.query", 
     query: "SELECT name,email FROM user WHERE uid = " + response.session.uid 
     }, 
function(response) { 
//Here you have acces to response from FB. 
//Use console.log(response) (in firebug in FF) to watch what is in it:) 
} 
);