How can I send a facebook user an email when they

2020-05-09 18:11发布

问题:

After a user clicks the Facebook like button on my page, I want to automatically send an email to them. Is this possible?

回答1:

You cannot enforce user to connect with your application and grant email permission by clicking Like Button.

You can however subscribe to edge.create event (using JS-SDK) and call FB.login to provide your user with ability to connect with your app (requesting email permission) so you'll be able to send an email to him. This is an optional and as I said can't be enforcement. As long as user able to see Like Button nothing can prevent him to click it.

Other option is displaying Like Button only to users who already authorized your application, so you can grab all the required info before he even able to like, later display Like Button, listen to event and send an email.

Update:
You'll probably want to read documentation on JS-SDK, especially on FB.Event.subscribe and FB.login.

Update2:
As it seems (according to other question you created) that you're trying to achieve this in Facebook Page tab. This making the task unsolvable since user will always see and be able to like page before you can do something. You can only request desired info from user in Page tab application and it's totally up to user to accept it or not...