3

我在玩弄Facebook的JS SDK和FQL,嘗試獲取某些查詢的結果,我嘗試的前兩個查詢fql)工作得很好,後半部分不起作用。Facebook JS SDK FB.Data.Query&query.wait方法不返回某些FQL查詢的結果

如果我叫FB.getAccessToken()取回自己的當前會話的訪問令牌,然後使用該訪問令牌來ping FQL端點它的工作原理:

https://api.facebook.com/method/fql.query?query=SELECT+name,+is_app_user+FROM+user+WHERE+uid+IN+(SELECT+uid2+FROM+friend+WHERE+uid1+=+ 504405294)&access_token=#############&format=json 

任何人都知道爲什麼使用它時不工作FB JS SDK?

// var fql = 'SELECT pic_square, uid FROM user WHERE uid = 504405294 OR uid = 100002624783324 OR uid = 1634269784 OR uid = 100002917463525'; 
     var fql = 'SELECT name, pic_square, sex FROM user WHERE uid = 100002624783324'; 
    // var fql = 'SELECT name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())'; //ORDER BY is_app_user DESC LIMIT 0, 1000'; 
    // var fql = 'SELECT uid2 FROM friend WHERE uid1 = 504405294'; 

     console.log(fql); 

     var query = FB.Data.query(fql); 
     query.wait(function(rows){ 
      console.log(rows); 

     }); 

編輯

爲了更加清楚一點,所述的console.log(行);調用.wait()永遠不會發生。控制檯是空白的。

回答

1

你好,你必須寫一些這樣的:

FB.api('/me', function(user) { 

     this.query = FB.Data.query("SELECT name, pic_square, sex FROM user WHERE uid =me()", user.id); 

       this.query.wait(function(rows) { 

        console.log(rows); 

       }); 


      }); 
+0

我很久以前寫了這個問題,但你可能想確保你沒有使用FB.Data.query和query.wait - 那些已被棄用,並將被立即刪除 –

+0

@CaseyFlynn我可以用什麼來代替? –