そのため、Facebook JSSDKでGraphAPIを使用しようとすると、Safariで次のエラーが発生します。
「OAuthException:現在のユーザーに関する情報を照会するには、アクティブなアクセストークンを使用する必要があります。」
SafariがxドメインのCookie設定に非常に厳しいという事実に関係しているのではないかと思ったので、Firefoxでcookie
オプションをfalseに設定して試してみましたFB.init()
。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'
});
だから私は疑問に思っています...リクエストaccess_token
でクエリパラメータを手動で設定する良い方法はありますか?FB.api()
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