简体   繁体   English

Facebook Send的Javascript事件处理程序

[英]Javascript event handler for Facebook Send

I'm integrating the Facebook Send button to our site and I'm trying to run some javascript as soon as the user sends the page to someone. 我正在将Facebook发送按钮集成到我们的网站,并且试图在用户将页面发送给某人后立即运行一些JavaScript。 With the Facebook Like button you can subscribe via javascript to the edge.create event which fires when the user Likes the page. 使用Facebook赞按钮,您可以通过javascript订阅edge.create事件,该事件在用户喜欢该页面时触发。 Is there an equivalent for the Facebook Send button? Facebook发送按钮是否具有等效功能? I tested it and the edge.create doesn't catch the Send button. 我对其进行了测试,并且edge.create无法捕获“发送”按钮。

So basically, is there any javascript event handler for the Facebook Send button? 因此,基本上,Facebook发送按钮是否有任何JavaScript事件处理程序?

根据https://developers.facebook.com/docs/reference/plugins/send/,您要查找的事件是“ message.send”

You should be able to add your own listeners by directly subscribing them to the classes prototype. 您应该可以通过直接将其订阅到类原型中来添加自己的侦听器。

For example, we use this to reposition the Like/Send menus accordingly once rendered: 例如,一旦渲染,我们就使用它来重新定位“喜欢/发送”菜单:

        var Like = FB.CLASSES['XFBML.Like'];
        Like.prototype.subscribe('xd.presentEdgeCommentDialog', function(a){

            setTimeout(function(){
              var el = $('#like-btn > span.fb_edge_comment_widget');
                    // console.log(a);
                    // console.log(el);
                    el.css('left', '-200px');
                    el.css('top', '20px');
            }, 500);
        })

The exact events you can subscribe depend on the class. 您可以订阅的确切事件取决于类。 You'll need to research this by looking to the JS SDK and then backtracking which events are being fired. 您需要研究此问题,方法是查找JS SDK,然后回溯正在触发的事件。

Good luck. 祝好运。

Hmm, have you tried to add a function that looks for the send button and adds your own click listener to it when it gets added? 嗯,您是否尝试过添加一个函数来查找发送按钮,并在添加按钮时为其添加自己的点击监听器?

You won't be able to get any information like response.session, but you can tally how many people click the button. 您将无法获得诸如response.session之类的任何信息,但是您可以统计有多少人单击该按钮。

I can see why they didn't include anything to subscribe to with FB.event.subscribe. 我可以看到为什么它们不包含任何要使用FB.event.subscribe进行订阅的内容。 When they like your page, connect elements on your page are populated with their information when the page reloads (you may reload the page in your method that gets fired). 当他们喜欢您的页面时,在页面重新加载时,页面上的connect元素将填充其信息(您可以在触发的方法中重新加载页面)。 They can send your page to someone without liking you. 他们可以在不喜欢您的情况下将您的信息发送给某人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM