
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
facebook-sdk
Advanced tools
This is a complete port of Facebook's PHP SDK library.
The Facebook Platform is a set of APIs that make your application more social. Read more about integrating Facebook with your web site on the Facebook developer site.
The node.js Facebook SDK is licensed under the Apache License, Version 2.0, as was the original library.
npm install facebook-sdk
Create a Facebook SDK object. The request
lets the object retrieve the
user's session from the http header. The response
lets the object write
the user a new session cookie. For more information on querying Facebook's
graph api, see developers.facebook.com.
var fbsdk = require('facebook-sdk'),
http = require('http');
http.createServer(function(request, response) {
// create a facebook object
var facebook = new fbsdk.Facebook({
appId : 'YOUR APP ID',
secret : 'YOUR API SECRET',
siteUrl: 'http://yoursite.com',
request : request,
response : response
});
// logged in
if (facebook.getSession()) {
response.end('<a href="' + facebook.getLogoutUrl() + '">Logout</a>');
// get my graph api information
facebook.api('/me', function(me) {
console.log(me);
});
// vs logged out
} else {
response.end('<a href="' + facebook.getLoginUrl() + '">Login</a>');
}
}).listen(80);
Using this as connect middleware, the following will attach a facebook object to each incoming http request.
var app = connect()
.use(fbsdk.facebook({
appId : 'YOUR APP ID',
secret : 'YOUR API SECRET',
siteUrl: 'http://yoursite.com',
})).
use(connect.router(function(app) {
app.get('/', function(req, res, next) {
if (req.facebook.getSession()) {
res.end('<a href="' + req.facebook.getLogoutUrl() + '">Logout</a>');
} else {
res.end('<a href="' + req.facebook.getLoginUrl() + '">Login</a>');
}
});
}));
Creating an adhoc object is done with new fbsdk.Facebook({...})
, and
creating middleware functions is fbsdk.facebook({...})
. This strikes
me as an ugly over-use of case sensitivity. Anybody with a better idea
about this api, please message me.
The tests have been ported to run using nodeunit. This was the easiest way to confirm the new node.js library works as expected. Some new tests have been added to cover edge cases, and others not relevant in the new environment have been removed.
FAQs
!!!Unmaintained!!! Consider using fb
We found that facebook-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.