drj14664 2012-08-13 02:08
浏览 106

Instagram redirect-uri因localhost而失败

I am writing a PHP app to fetch all my photos with Instagram using their API. However, what puzzles me is, I run the app on my hosted server it works perfectly fine and the same app running locally does not work.

Here are some points on the app workflow:

  1. The user sees the homepage and he will be prompted with 'sign-in with Instagram'
  2. User signs in with Instagram and authorizes the app.
  3. Instagram redirects the user.
  4. The app then makes a request for access_token and receives it.
  5. Using the access_token, the app will send further requests for user media
  6. The response is parsed and the links to the images are now provided to the user.

All the above mentioned process works fine on my hosted server but fails at 'Step 3.' and redirects user to home page of my app.

The problem is localhost being the redirect_uri. Does anyone have a solution to this problem to use the app locally?

P.S: I have registered two separate clients on Instagram: one for locally hosted development and the other on a web server.

Also, I have tried localtunnel. Did not help either.

  • 写回答

2条回答 默认 最新

  • douzhi1813 2012-12-25 07:35
    关注

    I was dealing with this issue trying to develop an Instagram App using NodeJS/Express.

    I got around this by using my computer's external local IP rather than localhost, which you can grep for. I assume you're on a *nix machine, so do a very simple (and crude)

    $ ifconfig | grep inet
    

    which will return you a few ip and MAC addresses, one of them being your external IP. However this is lousy because it means every time you switch IPs you'll have to update your application's redirect_url with Instagram as well as update any code that relies on it.

    Thankfully, there exists services like no-ip that will basically provide free DDNS service to you, so you need simply register a hostname with them and then drop that into your DEV env code as well as your development client's redirect url and you're set to go!

    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法