I am using Instagram feed API to show my Instagram posts on my Website. But some video URL shows 'URL signature expired'.
Any solution for me ?
An expiring link, also called signed URL, is a link to a file or object that is limited in time. Once it expires, the link is no longer valid. This has to advantage that the link cannot be used on another site since it expires in any given time by the rightful owner of the link.
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.
A signed URL is a URL that provides limited permission and time to make a request. Signed URLs contain authentication information in their query string, allowing users without credentials to perform specific actions on a resource.
The metadata & metadata & metadata part seems particularly relevant to the "URL signature mismatch" error - if you take a particular URL and remove various metadata chunks you get various error messages, typically either URL signature mismatch, or Bad URL timestamp.
You could use the media URL with some extra parameters as a solution to get the desired image instead of using the direct image link.
For example
https://www.instagram.com/p/Bo7OXJ3hYM8/media/?size=m
Notice the addon /media/?size=m
Letters could be t, m or l for different picture sizes
This should return you the desired image
Reference: https://www.instagram.com/developer/embedding/
Instagram has added URL signatures to their media URLs.
You can easily remove the URL signature using this regular expression: "vp.*/.{32}/.{8}/"
For example in PHP:
preg_replace('/vp.*\/.{32}\/.{8}\//', '', $mediaUrl)
On the other hand, I don't think that removing the URL signature is the best solution (is just a quick fix). The good one is to call again the Instagram api in order to get the new URL.
UPDATE
It seems that Instagram is currently checking the URL signature and returns a 403 "Access denied" error if the signature is not present, so now the only solution is to call the Instagram API again in order to get the new media URL.
UPDATE April 2018
Instagram has closed their "api.instagram.com/v1/media/" endpoint so now it's currently not possible to update the posts urls.
A possible solution is to download the media and store them in your own servers (I do not recommend this solution because it violates the terms of the Instagram API so do this at your own risk).
Another solution is to call the original endpoint where you have find the medias again (but currently it's difficult to manage the calls with the new API rate limit).
Also you can find some non-official Instagram APIs on github that could help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With