2012-02-08 73 views
0

我有一些代碼在一個月前工作...現在,當我檢查它時,它不起作用。我看到了什麼問題,控制檯說:「意外結束查詢」(#601)解析器錯誤:意外的查詢結束 - Javascript FB.api

我已經檢查Graph API工具上的這個查詢,它的工作原理!我使用與我的「應用程序」相同的權限。

這是FQL查詢:

SELECT uid,name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) ORDER BY name

這是完整的代碼:

// This code is in an html file 
window.fbAsyncInit = function() { 
FB.init({ 
     appId  : '226472757418610', 
     status  : true, 
     cookie  : true, 
     oauth  : true, 
     xfbml  : true 
    }); 
} 
... 
// this code is in a javascript file and the user is correctly logged in 
FB.api('/fql?q=SELECT uid,name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) ORDER BY name', function(amigos) { 
    console.log(amigos) 
    // it prints the message above 
}); 

我看不到任何錯誤!你能建議我的代碼有什麼問題嗎?

回答

2

如果任何與這個「查詢意外結束」的問題,你可以嘗試改變你的代碼爲這一個:

FB.api('/fql', { q:{"query1":"yourQuery"} }, function(response) { 
    // the response is different: 
    var x = response.data[0].fql_result_set; 
}); 

雖然不是最好的解決方案。

更新:這是沒有必要Q的對象。它可能是唯一的查詢,其結果可能是由response.data

+0

可能你或許可以解釋明白爲什麼這「不是最佳解決方案「?一種形式是否優先於其他形式? – 2013-02-06 18:36:26

相關問題