I am trying to make an app using Instagram's real-time api. I want to use Firebase to host my server. Below is my folder structure:
-main.js (instagram get and post requests here)
-server.js (setup express server here)
-firebase.json
-public (all firebase files)
--index.html
--scripts
--styles
I first make my subscription to Instagram by typing this in my command line:
curl -F 'client_id=7be53c459291486ead4916048ac434ad' \
-F 'client_secret=88ad262f9e57481bbf1ea7312d179a50' \
-F 'object=tag' \
-F 'aspect=media' \
-F 'object_id=turtles' \
-F 'callback_url=https://instagram-slideshow.firebaseapp.com/callback' \
https://api.instagram.com/v1/subscriptions/
I get an invalid response when I make the subscription request. Where should I put my server code? In my public folder? I cannot find any examples on how to use firebase to host your server. Can someone show me an example?
This is my server.js code:
var express = require('express');
var app = express();
require('./app.js')(app);
var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
});
And this is my main.js
module.exports = function(app){
// when instagram tries to GET my URL, I need to return the hub.challenge and hub.verify_token
app.get('/callback', function (req, res) {
res.send('Hello World!');
if(req.param("hub.verify_token") == "myVerifyToken") {
res.send(req.param("hub.challenge"));
}
else {
res.status(500).json({err: "Verify token incorrect"});
}
});
// when instagram sends a post request to my server, check for updates on my end
app.post('/', function (req, res) {
res.send('POST request to the homepage');
});
}