Giter Site home page Giter Site logo

facebook-template-nodejs's Introduction

Facebook/Heroku sample app -- Node.js

This is a sample app showing use of the Facebook Graph API, written in Node.js, designed for deployment to Heroku.

Run locally

Install dependencies:

npm bundle install

Create an app on Facebook and set the Website URL to http://localhost:5000/.

Copy the App ID and Secret from the Facebook app settings page into your .env:

echo FACEBOOK_APP_ID=12345 >> .env
echo FACEBOOK_SECRET=abcde >> .env

Launch the app with Foreman:

foreman start

Deploy to Heroku via Facebook integration

The easiest way to deploy is to create an app on Facebook and click Cloud Services -> Get Started, then choose Node.js from the dropdown. You can then git clone the resulting app from Heroku.

Deploy to Heroku directly

If you prefer to deploy yourself, push this code to a new Heroku app on the Cedar stack, then copy the App ID and Secret into your config vars:

heroku create --stack cedar
git push heroku master
heroku config:add FACEBOOK_APP_ID=12345 FACEBOOK_SECRET=abcde

Enter the URL for your Heroku app into the Website URL section of the Facebook app settings page, hen you can visit your app on the web.

facebook-template-nodejs's People

Contributors

dane avatar ddollar avatar mohamedmansour avatar mortenbagai avatar zeke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

facebook-template-nodejs's Issues

Doesn't work when Sandbox mode is on

When the app is private to non-developers, the app can't get its own information from the server (if this used to work, it was a security hole that's since been closed).

The app currently uses Faceplate's app function, which returns the response from graph.facebook.com/<app ID>, for its own app_id, so if that response fails (as it does in sandbox mode), anything that uses the app_id (such as opengraph data or, crucially, the "Log In" button) will be broken (using "undefined" as the app ID).

Where should I assign res.redirect

Hi, I am a super beginner about Node.js and Express

facebook-template-nodejs example works fine, then I would like to add res.redirect('/AnotherPage') when pushed a button. But I can not get solution. Because your code:

app.get('/',handle_facebook_request);
app.post('/',handle_facebook_request);

I wonder if I should write like as:

function handle_facebook_request(req,res){

if(req.param('button')){
res.redirect('/AnotherPage');
}
....
});

But I think it is wrong. Where should I assign res.redirect?

In case of pushed button, I always write as:

app.post('/', function(req,res){
if(req.param('button')){
res.redirect('/AnotherPage');
}
});

But I am not sure about your example case.

Thank you for your thoughts !

Vanilla apps are broken

http://cl.ly/text/3c192d252c0A

I thought it might be the restler dependency of faceplate getting quietly updated to a version with breaking API changes, but restler hasn't been updated in quite some time.

I tried updating faceplate from 0.0.4 to 0.5.0, but that doesn't solve anything: a request to / just hangs and times out.

This callback doesn't get fired: https://github.com/heroku/facebook-template-nodejs/blob/master/web.js#L47

To get up and running with a localhost:5000 OAuth setup:

git clone [email protected]:heroku/facebook-template-nodejs.git
cd facebook-template-nodejs
heroku config:pull -a glacial-falls-8460
npm install
foreman start

Open localhost:5000.

callbacks for me, get, post, fbql are missing error params needed by faceplate 0.6

I came across several issues getting this to work today:

faceplate index.js passes the error as the first param to the callback e.g.

this.me = function(cb) {
if (self.token) {
self.get('/me', function(err, me) {
console.log('get fb user: ' + JSON.stringify(me) + ', err: ' + err);
cb(err,me);
});
} else {
console.log('error get fb user no token');
cb(null,null);
}
};

but in web.js it has:

req.facebook.me(function(user) {

when should be

req.facebook.me(function(err, user) {

same issue applies to get and fql calls in handle_facebook_request

Also it looks like the data object that faceplate returns in the success callback for the get request stores the friends in a field called data so where faceplate calls the callback like this:

request.on('success', function(data) {
cb(null, data);
});

in web.js to get friends would be:

function(cb) {
// query 4 friends and send them to the socket for this socket id
req.facebook.get('/me/friends', { limit: 4 }, function(err, friends) {
req.friends = friends.data;
cb();
});
},

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.