Copied to clipboard

Flag this post as spam?

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


  • J 445 posts 862 karma points
    Mar 09, 2018 @ 16:38
    J
    0

    Getting started

    Purpose: Display my insta images on site

    Umbraco 7.. using webforms.

    So i downloaded and installed Skybrud via the umbraco packages section. Created a data type and lost as to what i need to do next? Reading the documentation im not sure if this add-on is applicable to me?

    Appreciate any help.

  • Anders Bjerner 487 posts 2989 karma points MVP 7x admin c-trib
    Mar 10, 2018 @ 16:26
    Anders Bjerner
    2

    Hi J,

    To clarify this package a bit, Skybrud.Social for Umbraco 7 adds a property editor that let's you authenticate with your Instagram account. Authentication gives you an access token, which you then can use to access the Instagram API.

    Skybrud.Social for Umbraco 7 itself doesn't handle more than just the authentication, but it includes another package - Skybrud.Social - which you can use for this.

    Here is a quick example on how you can show the most recent media of a given user (653220932 is the ID of our company account). This example however illustrates a MVC partial view, as I don't have any examples for WebForms.

    @using Skybrud.Social.Instagram.Objects
    @using Skybrud.Social.Instagram.Responses
    @inherits WebViewPage<Skybrud.Social.Instagram.InstagramService>
    @{
    
        // Make the request to the Instagram API
        InstagramRecentMediaResponse response = Model.Users.GetRecentMedia(653220932);
    
        // Get a reference to the response body
        InstagramMediasResponseBody body = response.Body;
    
        // Iterate through the returned media
        foreach (InstagramMedia media in body.Data) {
    
            <pre>@media.Link</pre>
    
        }
    
    }
    

    The partial view has a model of the type InstagramService. Your MVC view could look like this:

    @using Skybrud.Social.Instagram
    @using Skybrud.Social.Umbraco.Instagram.PropertyEditors.OAuth
    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    
    @{
    
        // Get the OAuth information stored in the property
        InstagramOAuthData instagram = Model.GetPropertyValue("instagram") as InstagramOAuthData;
    
        // Check whether the OAuth data is valid
        if (instagram != null && instagram.IsValid) {
    
            // Gets an instance of InstagramService based on the OAuth data
            InstagramService service = instagram.GetService();
    
            @Html.Partial("~/Views/Partials/Instagram/GetRecentMedia.cshtml", service)
    
        }
    
    }
    

    Again, I don't have any WebForms examples. It's mostly just C#, which works in both WebForms and MVC/Razor. So I hope the examples makes sense anyways ;)

  • J 445 posts 862 karma points
    Mar 13, 2018 @ 17:00
    J
    0

    Thanks, when i add the control to my template i get the error

    "Cannot bind source type Umbraco.Web.Models.PartialViewMacroModel to model type Umbraco.Core.Models.IPublishedContent."

    I've created another thread for this at

    https://our.umbraco.org/forum/templates-partial-views-and-macros/91091-cannot-bind-source-type-umbracowebmodelspartialviewmacromodel-to-model-type-umbracocoremodelsipublishedcontent

    in case its a separate issue from this control?

  • Anders Bjerner 487 posts 2989 karma points MVP 7x admin c-trib
    Mar 13, 2018 @ 22:00
    Anders Bjerner
    0

    Hi again,

    I haven't used macros in a really long time, so I'm not sure I'll be able to help. But I think you need to inherit from PartialViewMacroPage of UmbracoViewPage:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    

    UmbracoViewPage is more for regular MVC views and partial views.

Please Sign in or register to post replies

Write your reply to:

Draft