app.js
/*
 * Verify that the callback came from Facebook. Using the App Secret from
 * the App Dashboard, we can verify the signature that is sent with each
 * callback in the x-hub-signature field, located in the header.
 *
 * https://developers.facebook.com/docs/graph-api/webhooks#setup
 *
 */
Verify that the callback came from Facebook. Using the App Secret from
the App Dashboard, we can verify the signature that is sent with each
callback in the x-hub-signature field, located in the header.


Verify that the callback came from Facebook . Using the App Secret from the App Dashboard we can verify the signature that is sent with each callback in the x - hub - signature field located in the header .
function verifyRequestSignature(req, res, buf) {
	var signature = req.headers["x-hub-signature"];
	if (!signature) {
		throw new Error('Couldn\'t validate the signature.');
	} else {
		var elements = signature.split('=');
		var method = elements[0];
		var signatureHash = elements[1];
		var expectedHash = crypto.createHmac('sha1', config.FB_APP_SECRET)
			.update(buf)
			.digest('hex');
		if (signatureHash != expectedHash) {
			throw new Error("Couldn't validate the request signature.");
		}
	}
}
function verifyRequestSignature ( req , res , buf ) { var signature = req . headers [ "x-hub-signature" ] ; if ( ! signature ) { throw new Error ( 'Couldn\'t validate the signature.' ) ; } else { var elements = signature . split ( '=' ) ; var method = elements [ 0 ] ; var signatureHash = elements [ 1 ] ; var expectedHash = crypto . createHmac ( 'sha1' , config . FB_APP_SECRET ) . update ( buf ) . digest ( 'hex' ) ; if ( signatureHash != expectedHash ) { throw new Error ( "Couldn't validate the request signature." ) ; } } }
Verify that the callback came from Facebook.
Verify that the callback came from Facebook .