
January 27th, 2013, 07:43 AM
|
 |
For POny!
|
|
Join Date: Apr 2012
Location: Amsterdam
|
|
|
[Solved] Facebook subscribe sdk
Hi guys,
I am fiddling around with the facebook sdk, but something doesn't seem to work as expected. In their documentation they give an example on how to give a an alert when someone likes your page:
javascript Code:
Original
- javascript Code |
|
|
|
FB.Event.subscribe('edge.create', function(response) { alert('You liked the URL: ' + response); } );
I also loaded the sdk as mentioned in their documentation but it aint working. Does anyone happens to have experience with this little snippet?
Love to hearing from you.
CHeers!
A simplification of the file looks like this (note, ap id and stuff is correct in the real world  )
Code:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#" >
<head>
<title></title>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : 'YOUR_APP_ID', // App ID from the App Dashboard
channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File for x-domain communication
status : true, // check the login status upon init?
cookie : true, // set sessions cookies to allow your server to access the session?
xfbml : true // parse XFBML tags on this page?
});
// Additional initialization code such as adding Event Listeners goes here
};
// Load the SDK's source Asynchronously
// Note that the debug version is being actively developed and might
// contain some type checks that are overly strict.
// Please report such bugs using the bugs tool.
(function(d, debug){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";
ref.parentNode.insertBefore(js, ref);
}(document, /*debug*/ false));
</script>
<!-- end SDK -->
<!-- start face book like crap -->
<fb:like send="true" width="450" show_faces="true" />
<!-- end facebook like crap -->
<!-- start like alert -->
<script type="text/javascript">
FB.Event.subscribe('edge.create',
function(response) {
alert('You liked the URL: ' + response);
}
);
</script>
</body>
</html>
Last edited by aeternus : January 27th, 2013 at 07:54 AM.
|