質問

ところから始めるいくつかのイベント処理をユーザがクリックすると、ボタンを押します。

私のFacebookボタンがつくられていることが非同期で経由:

(function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
    '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
}());

ことになる。

私は、以下の機能と合わせ:

window.fbAsyncInit = function() {
    FB.init({status: true, cookie: true, xfbml: true});
    FB.Event.subscribe("xfbml.render", function() {
        console.log('xfbml.render');
        FB.Event.subscribe("edge.create", function(targetUrl) {
            console.log('edge.create');
        });
        FB.Event.subscribe("edge.remove", function(targetUrl) {
            console.log('edge.remove');
        });
    });
};

これまでに、負荷のページを取得します'xfbml.描画するのです。それかをクリックし、ボタン&取得します。

んでは吐き出コンソールにメッセージ'ます。作成.

はもう何が原因か。

私はこのページを公的にアクセス可能なサイトの前で現在の私のパリグ)がまだなかった。できる場合は再度求められます。

役に立ちましたか?

解決

利用するためXFBMLにすごいてくれるものでなければなりませXML名前空間に属性のルート要素のページです。この宣言XFBMLタグな描画するインターネット以下のように変更しました。

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="https://www.facebook.com/2008/fbml">

次に、 負荷のSDKを用いた標準的要素と呼(FB.init()).を指定する必要があります。a要素の名前 fb-根 ドキュメント内でのとします。

<div id="fb-root"></div>

してください追加のアプリidを内部のFB.init()関数

FB.init({
    appId  : 'YOUR APP ID',
    status : true, // check login status
    cookie : true, // enable cookies to allow the server to access the session
    xfbml  : true  // parse XFBML
  });

このコード:

<!doctype html>
<html lang="en" xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
  <meta charset="utf-8">
  <title>Facebook Like Button</title>
</head>
<body>
<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({appId: 'YOUR_APP_ID', status: true, cookie: true,xfbml: true});
    FB.Event.subscribe("edge.create", function(targetUrl) {
      console.log('edge.create');
    });
    FB.Event.subscribe("edge.remove", function(targetUrl) {
      console.log('edge.remove');
    });
  };
  (function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
      '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
  }());
</script>
<fb:like></fb:like>
</body>
</html>

他のヒント

で今後の参考:あいiframeボタン火イベントな運がxfbml FB.Event.subscribe("edge.create", f); に働きます。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top