-
-
Save ryonlife/7444409 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
{{#constant}} | |
<div id="fb-root"></div> | |
{{/constant}} | |
<div> {{> fb_pic}} {{loginButtons}}</div> | |
<br /> | |
<div><h2>Click to post to your feed:</h2> {{> feed}} </div> | |
</body> | |
<template name='feed'> | |
<input class='post' type='submit' value='Feed Post!' /> | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fbSdkLoader = function() { | |
if(!Session.get("is Facebook JDK loaded?")) { // Load Facebook JDK only once. | |
Session.set("is Facebook JDK loaded?", true); | |
window.fbAsyncInit = function() { // See Facebook JavaScript JDK docs at: https://developers.facebook.com/docs/reference/javascript/ | |
// Init the FB JS SDK | |
var initConfig = { | |
appId: 'YOUR_APP_ID', // App ID from the App Dashboard | |
channelUrl: Meteor.absoluteUrl("channel.html"), // channel url for FB | |
status: false, // check the login status upon init? | |
cookie: false, // set sessions cookies to allow your server to access the session? | |
xfbml: false // parse XFBML tags on this page? | |
}; | |
FB.init(initConfig); | |
}; | |
(function(d, debug) { // Load the SDK's source Asynchronously | |
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)); | |
} | |
}; | |
fbSdkLoader(); // run the loader | |
Template.feed.events({ // wiring for the button | |
'click .post': function(e) { | |
e.preventDefault(); | |
FB.ui({ | |
method: 'feed', | |
name: 'Facebook Dialogs', | |
link: 'http://fbrell.com/', | |
picture: 'http://fbrell.com/f8.jpg', | |
caption: 'Reference Documentation', | |
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.' | |
}, function(response) { | |
if(response && response.post_id) { | |
alert('Post was published.'); | |
} else { | |
alert('Post was not published.'); | |
} | |
}); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"connect": "2.11.0" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Meteor.startup(function() { // serve channel.html file programmatically | |
var connect; | |
connect = Meteor.require("connect"); | |
connect().use(connect.query(function(req, res, next) { | |
// Need to create a Fiber since we're using synchronous http | |
// calls and nothing else is wrapping this in a fiber | |
// automatically | |
return Fiber(function() { | |
if(req.url === "/channel.html") { | |
res.writeHead(200, { | |
'Content-Type': 'text/html' | |
}); | |
return res.end(''); | |
} else { | |
return next(); // if not a channel.html request, pass to next middleware. | |
} | |
}).run(); | |
})); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment