{"id":20760333,"url":"https://github.com/vanng822/facebook-nodejs","last_synced_at":"2025-06-23T10:34:09.753Z","repository":{"id":4079332,"uuid":"5184840","full_name":"vanng822/facebook-nodejs","owner":"vanng822","description":"Nodejs module for Facebook api","archived":false,"fork":false,"pushed_at":"2018-05-05T10:17:48.000Z","size":85,"stargazers_count":27,"open_issues_count":1,"forks_count":14,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-01T23:15:09.830Z","etag":null,"topics":["facebook-api","facebook-nodejs","fql","graph","graph-api","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vanng822.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-07-25T21:32:46.000Z","updated_at":"2025-02-21T15:46:45.000Z","dependencies_parsed_at":"2022-08-31T14:11:40.627Z","dependency_job_id":null,"html_url":"https://github.com/vanng822/facebook-nodejs","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/vanng822/facebook-nodejs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanng822%2Ffacebook-nodejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanng822%2Ffacebook-nodejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanng822%2Ffacebook-nodejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanng822%2Ffacebook-nodejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vanng822","download_url":"https://codeload.github.com/vanng822/facebook-nodejs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanng822%2Ffacebook-nodejs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261462301,"owners_count":23161926,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["facebook-api","facebook-nodejs","fql","graph","graph-api","nodejs"],"created_at":"2024-11-17T10:13:12.548Z","updated_at":"2025-06-23T10:34:04.739Z","avatar_url":"https://github.com/vanng822.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Facebook nodejs\nA simple module for querying Facebook graph api and fql\n\n## Usage example\n\t// run first: npm install express fbgraphapi body-parser cookie-parser express-session\n\tconst express = require('express');\n\tconst fbgraph = require('fbgraphapi');\n\tconst bodyParser = require('body-parser');\n\tconst cookieParser = require('cookie-parser');\n\tconst session = require('express-session');\n\n\tconst app = express();\n\t// parse application/x-www-form-urlencoded\n\tapp.use(bodyParser.urlencoded({ extended: false }));\n\tapp.use(cookieParser())\n\tapp.use(session({\n\t  secret: 'keyboard cat',\n\t  resave: false,\n\t  saveUninitialized: true,\n\t  cookie: { secure: false }\n\t}))\n\n\tapp.use(fbgraph.auth( {\n\t\t\tappId : \"...\",\n\t\t\tappSecret : \"...\",\n\t\t\tredirectUri : \"http://0.0.0.0:3000/\",\n\t\t\tapiVersion: \"v2.9\",\n\t\t\tskipUrlPatterns: [\"/favicon.ico\"]\n\t\t}));\n\n\tapp.get('/login', function(req, res) {\n\t\tconsole.log('Start login');\n\t\tfbgraph.redirectLoginForm(req, res);\n\t});\n\n\tapp.get('/', function(req, res) {\n\t\tif (!req.hasOwnProperty('facebook')) {\n\t\t\tconsole.log('You are not logged in');\n\t\t\treturn res.redirect('/login');\n\t\t}\n\t\t/* See http://developers.facebook.com/docs/reference/api/ for more */\n\t\treq.facebook.graph('/me', function(err, me) {\n\t\t    console.log(me);\n\t\t});\n\n\t\treq.facebook.graph('/me?fields=id,name', function(err, me) {\n\t\t    console.log(me);\n\t\t});\n\n\t\treq.facebook.me(function(err, me) {\n\t\t    console.log(me);\n\t\t});\n\n\t\t// /me/likes\n\t\treq.facebook.my.likes(function(err, likes) {\n\t\t    console.log(likes);\n\t\t});\n\n\t\tres.end(\"Check console output\");\n\t});\n\n\tapp.listen(3000);\n\n\n\nOr if have a valid access token for instance from javascript fb connect\n\t\n\tvar fb = new fbgraph.Facebook(accessToken, 'v2.2');\n\tfb.me(function(err, me) {\n\t\tconsole.log(me);\n\t});\n\nOr do stuff on behalf of the app or user with granted permissions\n\t\n\tvar fb = new fbgraph.Facebook(fbgraph.getAppId() + '|' + fbgraph.getAppSecret());\n\tfb.post('/{user-id}/feed', {message: 'Hello world'},function(err, res) {\n\t\tconsole.log(err, res);\n\t});\n\n## Facebook API reference\nVisit the links bellow for API documentation of Facebook API\nhttps://developers.facebook.com/docs/graph-api/using-graph-api\n\n## Methods\n### auth(config)\nconfig is an object with those properties\n* `appId` Facebook application Id\n* `appSecret` Secret hash key generated by Facebook\n* `redirectUri` The url to redirect to when user logged in.\n* `apiVersion` Which api version to use, example v2.2\n* `scope` Permissions/scope that your application asks for, optional and default empty.\n* `skipUrlPatterns` Array of patterns which to not apply authentication on. They can be regexp or string. If string a regexp will be created with wildcard appending at the end. If you want an exact url make sure specify regexp.\n\n### authenticate(req, res, next)\nThis method is returned when calling auth() above. When loggin is successfull it will assign a Facebook instance to req (see example above).\n\n### redirectLoginForm(req, res)\nThis method will redirect user to Facebook login form.\n\n### destroySession(req, res, clearCookie)\nThis method is for logging out user or for any reason want to clear user's logged-in info\n\n### getAppId()\nreturn app id, set via auth()\n\n### getAppSecret()\nreturn app secret, set via auth()\n\n## Classes\n### Facebook(accessToken, apiVersion)\n* `accessToken` Valid access token from Facebook (oauth_token).\n* `apiVersion` Which api version to use\n* `.graph(path, callback)` Main method for making call to Facebook API. Path can contain only /me/likes or with params like /me/likes?limit=3\n* `.post(path, params, callback) or post(path, callback)` Publishing to Facebook, see https://developers.facebook.com/docs/graph-api/using-graph-api/v2.0#publishing for detail. Path can contain post data such as /123/feed?message=hello\n* `.update(path, params, callback) or update(path, callback)` Updating a post on Facebook, see https://developers.facebook.com/docs/graph-api/using-graph-api/v2.0#updating for defail. Path can contain post data such as /123_123456789?message=edited\n* `.delete(path, callback)` Deleting a post on Facebook, see https://developers.facebook.com/docs/graph-api/using-graph-api/v2.0#deleting for defail\n* `.fql(query, callback)` Specific method for making fql query to Facebook API\n* `.search(params, callback)` params is an object which properties are any param based on this https://developers.facebook.com/docs/graph-api/using-graph-api#search\n* `.me(callback, fields)` Specific method to get info of the logged user, same as /me when using graph-method. Fields is comma-separated for instance fields=id,name\n* `.my` Instance of My class\n\nUsage: if have a valid accessToken for instance from js login\n\t\n\tvar fb = new Facebook(accessToken, 'v2.2');\n\tfb.me(function(err, me) {\n\t\tconsole.log(me);\n\t});\n\t\n\n### My(facebook)\nThis class uses internally to create object my (property in Facebook). This object wrap the me-object. Each connection type is a method. This means that you can make a call like\n\t\n\treq.facebook.my.friends(function(err, friends) {\n\t\tconsole.log(friends)\n\t});\n\t\n\t// OR for checkins\n\treq.facebook.my.checkins(function(err, checkins) {\n\t\tconsole.log(checkins)\n\t});\n\nSupported connection types are:\n\n* `friends`\n* `feed`\n* `likes`\n* `movies`\n* `music`\n* `books`\n* `albums`\n* `notes`\n* `permissions`\n* `photos`\n* `videos`\n* `events`\n* `groups`\n* `checkins`\n* `locations`\n\nIf you can not find a connection that Facebook has but not here you can use connection-method\n\t\n\treq.facebook.my.connection('{connection type}', function(err, result) {\n\t\tconsole.log(result)\n\t});\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvanng822%2Ffacebook-nodejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvanng822%2Ffacebook-nodejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvanng822%2Ffacebook-nodejs/lists"}