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

后端 未结 3 1003
一生所求
一生所求 2020-12-29 04:18

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 ?

相关标签:
3条回答
  • 2020-12-29 04:41

    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.

    0 讨论(0)
  • 2020-12-29 04:47

    At the time of writing, your only alternative is to store or cache the images somehow.

    For example, you could store the images in your database. Instagram platform policy requires that you delete the images when your application no longer needs them.

    Alternatively, if you use a CDN you can serve these images through an image proxy and then set long expiry dates on the CDN. This way you are not storing the images in a database, but your users can still see them after the URL signature expires.

    0 讨论(0)
  • 2020-12-29 05:01

    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/

    0 讨论(0)
提交回复
热议问题