Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Instagram/feed API media URL shows 'URL signature expired'

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 ?

like image 628
Arun Singh Avatar asked Dec 06 '17 06:12

Arun Singh


People also ask

What does it mean URL signature expired?

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.

Do Instagram URLs expire?

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.

What is URL signature?

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.

What is URL signature mismatch?

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.


2 Answers

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/

like image 180
Vladimir Afinello Avatar answered Sep 19 '22 04:09

Vladimir Afinello


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.

like image 32
Jordi Avatar answered Sep 23 '22 04:09

Jordi