var opengraph = require('opengraph-io')({appId: 'xxxxxx'}) ⁄⁄ <-- Enter your app_id!
var express = require('express');
var app = express();
app.get('/site/info', function (req, res) {
var siteUrl = req.query['url'];
opengraph.getSiteInfo(siteUrl, function(err, siteInfo){
console.log('hey err, err);
console.log('hey result', siteInfo);
res.json(siteInfo);
});
});
app.listen(3000, function() {
console.log('Example app listening on port 3000!');
console.log('Test this proxy with the following url:', 'http://localhost:3000/site/info?url=https%3A%2F%2Fnytimes.com');
});
To get the code above working, create a new directory and change into that directory from the command line (Linux or OSX)
mkdir example & cd example
Next, initialize the node package. Enter the information you are prompted for after entering the following
npm init
Next, install the ExpressJS and https packages
npm install express opengraph-io
Finally, create a server.js file with the contents above and start the app up
node server.js