15

I am getting the instagram images from instagram API. (endpoint : https://api.instagram.com/v1/users/self/media/recent?access_token= ). Then I am saving the image URLs that returning from the API call in the database and use them in the front-end. Exmple image url is below.

Example URL : https://scontent.cdninstagram.com/vp/xxx/xxx/xx/s150x150/xxx/x.x.x.x/xxxx_n.jpg

But sometimes the images doesn't show and when I go to the image particular link it shows 'URL signature expired'. What would be the reason for that?

I have referred the question about the same in a previous post in stack overflow and it didn't help. It said to save the image in a separate server. It won't work for me.

i am batman
  • 581
  • 3
  • 6
  • 21

2 Answers2

14

You can visit https://www.instagram.com/p/CQX8lKutaZU/media/?size=l

Use; "l" parameter for large,

"m" parameter for medium,

"t" parameter for small pictures.

But sadly it doesn't work on videos (it just shows thumbnails)

8

Instagram CDN URLs contain timestamp components that allow them to expire after a while. If you need the image to persist, you'll have to save it somewhere and serve that instead.

ceejayoz
  • 176,543
  • 40
  • 303
  • 368
  • @BertH It is not. See https://www.instagram.com/about/legal/terms/api/ - specifically this bit that implies storing is OK. "If you store or cache User Content, keep it up to date. For example, if a user marks a photo as 'private', you must reflect that change by removing the content as soon as reasonably possible." – ceejayoz Mar 15 '19 at 15:12
  • The best way is to get the updated image URL through a cron job once every 4 or 5 days. – i am batman Dec 02 '19 at 04:10