LoginSignup
2
2

More than 5 years have passed since last update.

FacebookのJavaScript SDKでバージョンを1.0から2.xに上げたらAPIが叩けなくなった人へ

Last updated at Posted at 2014-11-19

Graph APIのバージョンを1.0から2.xに上げた途端、なんか動かなくなって困ってる人へ。
もしかしたらFB.init()の「status」パラメータが原因かも?

Determines whether the current login status of the user is freshly retrieved on every page load. If this is disabled, that status will have to be manually retrieved using .getLoginStatus(). Defaults to true.
https://developers.facebook.com/docs/javascript/reference/FB.init/v1.0

v1.0ではデフォルトがtrueだったのに…

Determines whether the current login status of the user is freshly retrieved on every page load. If this is disabled, that status will have to be manually retrieved using .getLoginStatus(). Defaults to false.
https://developers.facebook.com/docs/javascript/reference/FB.init/v2.2

v2.xではこっそりfalseに変わっています。

FB.init({
    appId: '123456789',
    version: 'v2.2',
    xfbml: true,
    status: true
});

認証が必要なAPIを叩く際には、上記のようにstatusを明示的に指定してあげるか、FB.getLoginStatus()を使いましょう。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2