Help us understand the problem. What is going on with this article?

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

More than 5 years have passed since last update.

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()を使いましょう。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away