As of April 4th 2018, Instagram has suddenly decided to close down most of their Platform API. This unfortunately also means that many of the features in this package are no longer working. You can read more about the changes to the Instagram Platform API via the links below:
As of April 4th 2018, Instagram has suddenly decided to close down most of their Platform API. This unfortunately also means that many of the features in this package are no longer working. You can read more about the changes to the Instagram Platform API via the links below:
Getting information about a media
If you already have the ID of an Instagram media, you can request information about the media through the GetMedia
method. A quick example for this could look like this Razor example:
@using Skybrud.Social.Instagram.Objects.Media
@using Skybrud.Social.Instagram.Responses.Media
@inherits WebViewPage<Skybrud.Social.Instagram.InstagramService>
@{
// Make the request to the API
InstagramGetMediaResponse response = Model.Media.GetMedia("1482657170024975745_653220932");
// Get a reference to the media (the properties follow the underlying JSON)
InstagramMedia media = response.Body.Data;
<div>
<img src="@media.Images.StandardResolution.Url" alt="" /><br />
<a href="@media.Link"><small>@media.CreatedTime.ToRfc2822</small></a><br />
<p>@media.CaptionText</p>
</div>
}
In this example, you will get the media as an instance of InstagramMedia
, which however is just a base class. Since an Instagram media can be either an image or a video, these are represented by the InstagramImage
and InstagramVideo
classes respectively. Both classes inherit from InstagramMedia
.
While the InstagramImage
class doesn't really have any extra properties compared to InstagramMedia
, the InstagramVideo
will have extra properties about the video.
It's also worth mentioning that if you need the public_content
scope in order to request information about media of other users.
Shortcodes
Since you might not know the ID of the media prior to making the request to the Instagram API, you can also request information based on the media's shortcode instead. Eg. if the web URL of the media is https://www.instagram.com/p/BSTdNc3Bk2B/
, the shortcode of the media is BSTdNc3Bk2B
.
Compared to the example from before, you should instead use the GetMediaFromShortcode
method. This will look like:
@using Skybrud.Social.Instagram.Objects.Media
@using Skybrud.Social.Instagram.Responses.Media
@inherits WebViewPage<Skybrud.Social.Instagram.InstagramService>
@{
// Make the request to the API
InstagramGetMediaResponse response = Model.Media.GetMediaFromShortcode("BSTdNc3Bk2B");
// Get a reference to the media (the properties follow the underlying JSON)
InstagramMedia media = response.Body.Data;
<div>
<img src="@media.Images.StandardResolution.Url" alt="" /><br />
<a href="@media.Link"><small>@media.CreatedTime.ToRfc2822</small></a><br />
<p>@media.CaptionText</p>
</div>
}