Instagram Getting recent media of a user

Getting recent media of a user

To get the most recent media of a given user, you code can look something like the snippet below:

@using Skybrud.Social.Instagram
@using Skybrud.Social.Instagram.Fields
@using Skybrud.Social.Instagram.Models.Graph.Media
@using Skybrud.Social.Instagram.Responses.Graph.Media
@inherits WebViewPage<InstagramService>

@{

    // Declare the fields to be returned by the API
    InstagramFieldsCollection fields = "caption,thumbnail_url,id,ig_id,like_count,media_type,media_url,permalink,owner,username,comments_count";

    // Make the request to the Graph API
    InstagramMediaListResponse response = Model.Graph.Users.GetRecentMedia("1234", fields);

    foreach (InstagramMedia media in response.Body.Data) {

        <pre>@media.MediaUrl</pre>

    }

}

Notice how the snippet specifies the fields that should be returned by the Graph API. If left out, only the ID of each media will be returned.