Question

After the Facebook Like button has been pressed, "You just liked the page" should be alerted.

Ive been sitting over this problem over the last 2 nights and I read everything I could find but still have no clue how to do it. Some people say you need an developers account, some say you don't and all in all Im even more confused right now than I was before.

I am so greatful if anyone of you could be the first one to write simple comprehendible instructions on how to solve that problem, a "Facebook callback for Dummies".

PS: I can only use HTML and javascript!

PPS: If you know how to do it with Twitter and Google+, that's good too!

That's what I found on the facebook page: Page Likes edge.create

edge.create is fired when someone clicks a like button on your page to like something. edge.remove

edge.remove is fired when someone clicks a like button on your page to unlike something. Callback

The callback for both of these events will be called with two arguments: Name Type Description

href

string

URL of the like target.

widget

object

Document element for the button that was pressed. Example

Here's an example of a callback that can handle either the edge.create or edge.remove event:

var page_like_or_unlike_callback = function(url, html_element) {
  console.log("page_like_or_unlike_callback");
  console.log(url);
  console.log(html_element);
}

// In your onload handler
FB.Event.subscribe('edge.create', page_like_or_unlike_callback);
FB.Event.subscribe('edge.remove', page_like_or_unlike_callback);
Was it helpful?

Solution

For Facebook you can use the Edge Events:

https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/

But you do need to create an App for that (no SSL needed for external Websites, no worries), and i guess you already included the JavaScript SDK: https://developers.facebook.com/docs/javascript/quickstart

For Twitter, this may help you: https://dev.twitter.com/docs/intents/events (see "Intent Events")

Google+ Callback: https://developers.google.com/+/web/+1button/ (see the Extended Options)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top