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 user
The Users
endpoint exposes a GetUser
method that lets you get information about a given user based on their user ID.
It is not possible to get information about a user based on their username directly, so you will instead have to search for their username, and then get the user ID from the search results.
The GetUser
method will return an object representing the entire HTTP response from the API, so have a look at the example on how to get the information of the user via the InstagramUser instance:
@using Skybrud.Social.Instagram.Objects.Users
@using Skybrud.Social.Instagram.Responses.Users
@inherits WebViewPage<Skybrud.Social.Instagram.InstagramService>
@{
// Make the call to the API
InstagramGetUserResponse response = Model.Users.GetUser(189413627);
// Get the user object (the "Data" property matches the JSON)
InstagramUser user = response.Body.Data;
// Print some information about user
<p>Id: @user.Id</p>
<p>Name: @(user.HasFullName ? user.FullName : user.Username)</p>
}
Getting information about the authenticated user
If you need to get information about the authenticated user, and doesn't know his/her user ID, you can use the GetSelf
method in instead:
@using Skybrud.Social.Instagram.Objects.Users
@using Skybrud.Social.Instagram.Responses.Users
@inherits WebViewPage<Skybrud.Social.Instagram.InstagramService>
@{
// Make the call to the API
InstagramGetUserResponse response = Model.Users.GetSelf();
// Get the user object (the "Data" property matches the JSON)
InstagramUser user = response.Body.Data;
// Print some information about user
<p>Id: @user.Id</p>
<p>Name: @(user.HasFullName ? user.FullName : user.Username)</p>
}
Both the GetUser
and GetSelf
methods will return an instance of InstagramUserResponse. As you can see in the example above, this class will expose information about the user through the InstagramUser class.