Instagram Getting information about a user

Getting information about a user

Assuming the access token you're using has the necessary permissions, you can get information about an Instagram business account via the GetUser method, where the first parameter is the Facebook ID of the Instagram user (which is not the same as the Instagram ID of the user). The second parameter is a collection of fields that should be returned by the API.

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

@{

    try {

        // Declare the fields to be returned by the API
        InstagramFieldsCollection fields = "biography,followers_count,follows_count,id,ig_id,media_count,name,profile_picture_url,username,website";

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

        // Get the user from the response
        InstagramUser user = response.Body;

    } catch (InstagramHttpException ex) {

        <pre>@ex.Error.Message</pre>

        return;

    }

}

Given the above example was executed successfully, you can write out some basic information about the user:

<table class="table details">
    <tbody>
    <tr>
        <th>Biography</th>
        <td>@user.Biography</td>
    </tr>
    <tr>
        <th>FollowersCount</th>
        <td>@user.FollowersCount</td>
    </tr>
    <tr>
        <th>FollowsCount</th>
        <td>@user.FollowsCount</td>
    </tr>
    <tr>
        <th>Facebook Id</th>
        <td>@user.Id</td>
    </tr>
    <tr>
        <th>Instagram Id</th>
        <td>@user.InstagramId</td>
    </tr>
    <tr>
        <th>MediaCount</th>
        <td>@user.MediaCount</td>
    </tr>
    <tr>
        <th>Name</th>
        <td>@user.Name</td>
    </tr>
    <tr>
        <th>ProfilePictureUrl</th>
        <td>@user.ProfilePictureUrl</td>
    </tr>
    <tr>
        <th>Username</th>
        <td>@user.Username</td>
    </tr>
    <tr>
        <th>Website</th>
        <td>@user.Website</td>
    </tr>
    </tbody>
</table>