rethinkdb / cats-of-instagram

51 stars 22 forks source link

Can't get example to work - no post requests incoming from Instagram #2

Closed stochastic-thread closed 9 years ago

stochastic-thread commented 9 years ago

I uploaded my version of the repo here: https://github.com/arthurcolle/catatonic

I am running it on http://colle.space:8091

and added a line console.log("Got a post"); in app.js to start to debug whether instagram is really sending out a post request to my app and I havent seen it print to the console yet so I'm wondering if maybe I did something wrong? Thanks for any help

coffeemug commented 9 years ago

/cc @segphault

segphault commented 9 years ago

Do you have the correct public-facing hostname in your config.js file?

Facebook's realtime APIs use webhook callbacks, which means that the callback_url property populated in subscribeToTag needs to point to the right place. In your case, because you aren't binding to port 80 on the public-facing side, you might need to put the port number in config.host like this: "colle.space:8091". Basically, you want callback_url to say http://colle.space:8091/publish/photo.

I suspect that the host config is the most likely culprit if you aren't getting any hits at all. That said, there are a few other things that you can do to get more information. While debugging the app, I would typically run it locally and use a tool like ngrok to expose it to the public internet. That's often useful if you want to be able to see the actual requests that are coming in before they hit the app. Another thing that sometimes helps is using a tool like Postman to manually craft a POST request equivalent to the one in subscribeToTag so that you can play with the settings and figure out what isn't working.

stochastic-thread commented 9 years ago

I had the same thought as you but I added my config.js to .gitignore because it had my client credentials information but I will try your suggestions and get back to this later this evening.

stochastic-thread commented 9 years ago
module.exports = {
  instagram: {
    client: "HIDDEN",
    secret: "HIDDEN2",
    verify: "HIDDEN2"
  },

  database: {
    host: "colle.space",
    port: 28015,
    db: "cats"
  },

  host: "colle.space",
  port: 8091
}

As you can see the port is being specified correctly. Additionally, then I appended http:// to both "host:" fields above it threw tons of errors and the app couldn't connect to the RethinkDB instance. The Instagram server field (when setting up a client) uses the following: http://colle.space:8091 as the callback URL

segphault commented 9 years ago

You need to add the port to the host field in the config file:

module.exports = {
  instagram: { ... },
  database: { ... },
  host: "colle.space:8091",
  port: 8091
}
stochastic-thread commented 9 years ago

Unfortunately I'm getting the same problem, it still won't even print to console (my check as to whether Insta is making a post request to my application)

https://github.com/arthurcolle/catatonic

stochastic-thread commented 9 years ago

Hey dude thanks a lot, ngrok is the bomb

Will commit the code fixes to the catatonic repo in case you want to update the cats-of-instagram one accordingly, the socketio object needed to listen to the express 'server' object, and then server needed to listen to the correct port. Had to change the ordering of some of the LOC in app.js but in the end it worked.