Search code examples
phpinstagraminstagram-api

How to find SHORTCODE or SHORTLINK of a media from Instagram API?


I am going to embed some medias of the logged in user by following Instagram API:

https://api.instagram.com/oembed?url=http://instagr.am/p/fA9uwTtkSN/

But it needs shortlink or at least shortcode to produce the link. Unfortunately using below API neither returns a shortlink nor shortcode.

https://api.instagram.com/v1/users/self/media/recent/?access_token=ACCESS-TOKEN

Any idea to solve this?


Solution

  • In the JSON API response there is a "link", that is the shortlink url:

        {
            "data": [{
                "comments": {
                    "count": 0
                },
                "caption": {
                    "created_time": "1296710352",
                    "text": "Inside le truc #foodtruck",
                    "from": {
                        "username": "kevin",
                        "full_name": "Kevin Systrom",
                        "type": "user",
                        "id": "3"
                    },
                    "id": "26621408"
                },
                "likes": {
                    "count": 15
                },
                "link": "http://instagr.am/p/BWrVZ/",
                "user": {
                    "username": "kevin",
                    "profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_3_75sq_1295574122.jpg",
                    "id": "3"
                },
    ....