所以我試圖用與Facebook的JS SDK中的圖形API和我得到的Safari以下錯誤:使用Facebook圖形API被打破
「OAuthException:必須使用活動的訪問令牌來查詢有關當前用戶的信息。」
我懷疑它與Safari對x域cookie設置非常嚴格的事實有關,所以我在Firefox中試過它,cookie
選項在FB.init()
中設置爲false。我的確發現我的FB.api()
請求中出現同樣的錯誤。
FB.init({
appId: "<%= app_id %>",
status: true, // check login status
// We cannot rely on this cookie being set in an iframe. I found this
// out because the Graph API was not working in Safari.
// cookie: true, // enable cookies to allow the server to access the session
xfbml: true, // parse XFBML
channelUrl: window.location.protocol + '//' + window.location.host + '/fb/canvas/channel.html'
});
所以我不知道...有手動設置在FB.api()
請求access_token
查詢參數的好辦法?
如果FB.init()
Cookie會設置正確,這個是什麼FB.api()
請求參數如下所示:
access_token xxxxxxxxxxxx|1.xxxxxxxxxxxxxxxxxxxxxx__.3600.xxxxxxxxxx-xxx|xxxxxxxxxxxxxxxxxxxxxxxxxxx
callback FB.ApiServer._callbacks.xxxxxxxxxxxxxxx
pretty 0
sdk joey
在Safari瀏覽器(或當cookie
FB.init()
選項未設置)的FB.api()
請求參數如下所示:
callback FB.ApiServer._callbacks.xxxxxxxxxxxxxxx
pretty 0
sdk joey
現在...顯然我的應用程序有能力在服務器端生成access_token
...我想知道是否有任何方法我可以手動設置FB.api()
使用我的服務器端生成的access_token
。
我想有另一種方法來做到這一點。基本上,由於我們有一次機會在填充iFrame的初始post請求中設置cookie,所以我們可以使用這個機會來模擬FB JS中在FB.init()期間嘗試設置的`fbs_xxxxxxxxx` cookie。現在... SDK設置的cookie值如下所示:`fbs_xxxxxxxxx =「access_token = xxx&expires = xxx&secret = xxx&session_key = xxx&sig = xxx&uid = xxx」`。 `access_token`和`expires`部分很容易。但我在計算其他部分時遇到了一些麻煩。 – 2011-02-01 17:01:19