Node.js 如何在节点上使用Express.js从Instagram API接收帖子
我正在尝试设置一个应用程序,该应用程序将实时显示带有特定标签的Instagram帖子 这是我到目前为止所做的Node.js 如何在节点上使用Express.js从Instagram API接收帖子,node.js,express,instagram,Node.js,Express,Instagram,我正在尝试设置一个应用程序,该应用程序将实时显示带有特定标签的Instagram帖子 这是我到目前为止所做的 var io = require('socket.io').listen(app) , fs = require('fs') , connect = require('connect') , $ = require('jquery') // , ngrok = require('ngrok') , express = require('express') , app
var io = require('socket.io').listen(app)
, fs = require('fs')
, connect = require('connect')
, $ = require('jquery')
// , ngrok = require('ngrok')
, express = require('express')
, app = express()
, port = process.env.PORT || 5000;
//ngrok.connect(5000, function (err, url) {
//})
app.listen(port);
function handler (req, res) {
fs.readFile(__dirname + '/index.html',
function (err, data) {
if (err) {
res.writeHead(500);
return res.end('Error loading index.html');
}
res.writeHead(200);
res.end(data);
});
}
io.sockets.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.emit('stuff', function() {
console.log("http server listening on %d", port);
});
socket.on('my other event', function (data) {
console.log(data);
});
});
// Defining Routes
app.use(express.static(process.cwd() + '/public'));
app.get('/', function (req, res) {
res.send('Testing');
});
app.get('/endpoint', function (req, res) {
// For convention's sake, we only respond to this if it's a properly formatted request from Instagram
if (req.query['hub.challenge']) {
// First we check if hub.challenge exists in the query, then we do something
res.send(req.query['hub.challenge']);
}
});
这就是我错了/迷路的地方
app.use(express.bodyParser());
app.post('/endpoint', function (req, res) {
console.log(req.body);
});
我相信我已经遵循了Instagram API中的订阅教程(设置hub.challenge并设置订阅),但是如何查看它应该发送的传入JSON数据呢?除此之外,我如何操作JSON在前端显示图片
感谢您的帮助