FB.event.subscribe comment.create acting without action from user [duplicate]

瘦欲@ 提交于 2019-12-02 13:06:27

PHP is executed server-side. By the time the callback is fired, the PHP has already executed (when the page was requested).

Instead, you need to make an AJAX call inside of your callback to a PHP script that will do whatever it is that you need it to do:

window.fbAsyncInit = function(){ 
    FB.Event.subscribe('comment.create', function(response){
        $.post('/sendemail.php');
    });
};

Put the rest of your code in sendemail.php

This assumes you are using jQuery.

Note: This is a pretty bad idea considering that, without any validation, a user can just send repeated requests to sendemail.php and spam the heck out of someone's mailbox. Consider security, rate limiting, etc.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!