2012-10-16 17 views
8

私はxfbmlを使いたくありません。私は以下のようにiframeのようなボタンを使う必要があります。しかし、それは発砲していないedge.createiframeのようなボタンは発砲しませんedge.create

<div id="fb-root"></div> 
<script src="http://connect.facebook.net/en_US/all.js"></script> 
<script> 
// initalize your Facebook App 
    FB.init({ 
    appId : '113869198637480', 
    status : true, // check login status 
    cookie : true, // enable cookies to allow the server to access the session 
    xfbml : true // parse XFBML 
    }); 
// subscribe to the event 
FB.Event.subscribe('edge.create', function(response) { 
    alert('you liked this'); 
}); 
FB.Event.subscribe('edge.remove', function(response) { 
    alert('you unliked this'); 
}); 
</script> 

<iframe id="test" src="http://www.facebook.com/plugins/like.php? 
     href=http://google.com/&amp; 
     layout=button_count&amp; 
     show_faces=false&amp; 
     width=50&amp; 
     action=like&amp; 
     colorscheme=light&amp; 
     height=21" 
     scrolling="no" frameborder="0" 
     style="border:none; overflow:hidden; width:50px; 
       height:21px;" 
     allowTransparency="true"> 
+2

iframeのバージョンを使用していない場合は__not__できません。 – CBroe

+0

どのような回避策ですか? –

+1

はい、iframeバージョンは使用しないでください; – luschn

答えて

8

これは完全に予想されます。 javascriptコールバックは、同様のボタンを含むJavascript版のソーシャルプラグインを使用している場合にのみ使用できます。

これはLike Button documentationに記載されている:

How do I know when a user clicks a Like button? 

If you are using the XFBML version of the button, you can subscribe to the 'edge.create' event through FB.Event.subscribe. 

あなたは直接のiFrameなどのようにボタンが含まれている場合、戻ってあなたのjavascriptのコードに伝播するFacebookのサーバーからのイベントのための方法はありません - FacebookのJavascriptがLikeボタンのXFBMLバージョンを使用しているときにSDKがこの通信を処理します

+0

ありがとう、私はまだ、私はまだiFrameのようなボタンを検出する方法(醜いとハッキー)が必要であることを知っている – CamelCamelCamel

+0

残念ながら – Igy

+1

あなたがクライアントを得るかもしれないようなボタンの正確な座標(x、y)マウスの座標をクリックして、それがLikeクリックであると仮定します。 – erichste

関連する問題