Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Søren Mastrup 108 posts 473 karma points c-trib
    Oct 09, 2015 @ 19:37
    Søren Mastrup
    0

    Instagram video URL

    How do I access the video URL for instagram videos?

    Using @media.Standard only returns the standard thumbnail for both images and videos - I am looking for the URL to the .mp4 file.

  • Anders Bjerner 407 posts 2269 karma points MVP 3x admin c-trib
    Oct 09, 2015 @ 22:18
    Anders Bjerner
    100

    Hi Søren,

    When making calls to the Instagram API to get a list of media, Skybrud.Social will parse these into instances of InstagramMedia (which is actually an abstract class).

    Depending on whether a given media is either an image or a video, the actual class will be either InstagramImage or InstagramVideo correspondingly (since both of these classes inherit from the abstract InstagramMedia class).

    Here is a small example on how to use and check against the type of media:

    @using System.Web.Mvc.Html
    @using Skybrud.Social.Instagram
    @using Skybrud.Social.Instagram.Objects
    @using Skybrud.Social.Instagram.Responses
    @inherits System.Web.Mvc.WebViewPage
    
    @{
    
        InstagramService service = InstagramService.CreateFromClientId("client id");
    
        InstagramRecentMediaResponse response = service.Tags.GetRecentMedia("umbraco");
    
        foreach (InstagramMedia media in response.Body.Data) {
    
            InstagramImage image = media as InstagramImage;
            InstagramVideo video = media as InstagramVideo;
    
            if (image != null) {
    
                <div style="margin: 20px auto; width: @(image.Images.StandardResolution.Width)px">
                    <img src="@image.Standard" alt="" />
                </div>
    
            } else if (video != null) {
    
                InstagramMediaSummary size = video.Videos.StandardResolution;
    
                <div style="margin: 20px auto;  width: @(size.Width)px;">
                    <video style="width: @(size.Width)px; height: @(size.Height)px" controls>
                        <source src="@size.Url" type="video/mp4" />
                    </video>
                </div>
    
            }
    
        }
    
    }
    

    Hope this answers your question ;)

  • Søren Mastrup 108 posts 473 karma points c-trib
    Oct 11, 2015 @ 19:53
    Søren Mastrup
    0

    Thank you Anders! That did the trick!

Please Sign in or register to post replies

Write your reply to:

Draft