8
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

JavaScript SDK 変更について

Last updated at Posted at 2014-11-28

バージョン1.0 から バージョン2.0 へのアップグレードに伴い
サイト内に設定する「いいね!」ボタンを書き換える件は、
Facebookページ内の JavaScript SDK(ページの高さを調整したり)も対象?と思ったのでまとめた件。

(参考)

→JavaScript SDK を all.js からsdk.js に変更しましょう。(2015年4月30日までに) | Sunday In The Park
http://snowadays.jp/2014/11/3307

※Facebook SDK 紹介ページ@Facebook公式

→Quickstart: Facebook SDK for JavaScript
https://developers.facebook.com/docs/javascript/quickstart/v2.2?locale=ja_JP
→Facebook Platform Upgrade Guide
https://developers.facebook.com/docs/apps/upgrading/?locale=ja_JP

【変更箇所】

・FB.init内の項目に「version: 'v2.1'」を追加
(直前の記述の最後に「,」を追加するのを忘れないこと)
・「all.js」→「sdk.js」

(記述例)

<div id="fb-root"></div>
<script type="text/javascript" src="https://connect.facebook.net/en_US/sdk.js"></script>
<script>(function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol + '//connect.facebook.net/ja_JP/sdk.js';
    document.getElementById('fb-root').appendChild(e);
}());
window.fbAsyncInit = function() {
    FB.init({
        appId: '【アプリID】',
        status: true,
        xfbml: true,
        version: 'v2.1'
    });
    FB.Canvas.setAutoGrow();
};
</script>

(サンプルによっては「v2.0」だったり「v2.1」だったりしてるけど、最新はなんぼなんだろう…。)

(2014.12.04.追記)

ここに書いてあった。
Facebook Platform Changelog ※日本語
https://developers.facebook.com/docs/apps/changelog?locale=ja_JP

最新のAPIは、2014年4月30日に導入されたバージョン2.0です。

(2015.05.18.追記)

最新情報はこっちみたいです。
This method is used to initialize and setup the SDK.(Facebook Developers) ※英語
https://developers.facebook.com/docs/javascript/reference/FB.init/

version : 'v2.3' // or v2.0, v2.1, v2.0

=「v2.x」で動作?(作成時点での最新のものを使っておくと安心?)
(コメント内 2つ目の「v2.0」は、「v2.2」のコピペミスかなー)

(2016.02.16.追記)

今は「v2.5」みたい。
(久しぶりに調べた。)

(2016.06.28.追記)

APIの最新バージョンはバージョン2.6です。リリース日は2016年4月12日です。

※使用期限が迫っているので、チェックした方がよさそう。
v2.0 : 2016年8月7日
v2.1 : 2016年10月30日

8
7
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
8
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?