abjerner / Skybrud.Social

Skybrud.Social is a framework in .NET for integration with various social services like Twitter, Facebook and Instagram. The framework will handle all the technical parts and API communication so you don't have to.
http://social.skybrud.dk/
MIT License
96 stars 32 forks source link

FacebookPostOptions not mapping story field #72

Closed Brighty28 closed 5 years ago

Brighty28 commented 7 years ago

Can you advise how I get story attachments for example: capture

These are the fields I have so far

 FacebookGetPostsOptions options = new FacebookGetPostsOptions
        {
            Identifier = "FitCubs",
            Fields = "attachments,cover,name,likes,link,posts,created_time,message,type,full_picture,picture,source,caption,media,url"
        };

And the code:

@foreach (FacebookPost post in response.Body.Data) {

<section>
        <h3><a href="@post.Link">@post.Name</a></h3>
        <ul class="meta">
                      <li class="timestamp">@post.CreatedTime.ToString("f")</li>
        </ul>
            @if (string.IsNullOrWhiteSpace(post.Source) == false)
                        {
                if(post.Source.Contains("youtube"))
                {
                    <iframe width="420" height="315"
                        src="@post.Source?autoplay=1">
                    </iframe>                                   
                }
                else
                {
                    <video width="320" height="240" controls>
                        <source src="@post.Source" type="video/mp4">
                        Your browser does not support the video tag.
                    </video>
                }
            }
                      else if (string.IsNullOrWhiteSpace(post.Picture) == false)
                      {
                        <a href="@post.Link" class="image image-full"><img src="@post.Picture" alt="" /></a>
                      }
              else if (string.IsNullOrWhiteSpace(post.Story) == false)
             {
            <a href="@post.Link" class="image image-full"><img src="@post.Story" alt="" /></a>
             }
            <p>@post.Message</p>

            <a href="@post.Link" class="button">Continue Reading</a>
        </section>

    }
abjerner commented 7 years ago

@Brighty28 I can see that the API exposes an attachment property in the JSON for some of the posts, but Facebook haven't documented this property in their own documentation (at least what I can see), so Skybrud.Social doesn't support it either.

Nevertheless, I will look into wether it makes sence to add support for the property anyways ;)

Brighty28 commented 7 years ago

@abjerner thank you for coming back to me I was looking at Graph API Explorer: Graph API Explorer

With the below fields: FitCubs/posts?fields=child_attachments,name,picture,story,created_time,message,attachments,source

If that helps also interested in being able to access the height and width attributes for media if possible:

abjerner commented 6 years ago

Sorry for the waiting time. Facebook still has no documentation for getting attachments as part of the post object, but I've tried building something based on API responses and the documentation for the attachments edge. This is now part of Skybrud.Social.Facebook.

When you have an instance of FacebookPost, you can now access an array of attachments through the Attachments property. I haven't found anything so far about child attachments (not even from API responses), but an attachment may have a number sub attachments (also not documented by Facebook from what I can tell).

I've tried to map the properties I've discovered via the API, so you'll now also be able to get the width and height of the image of an attachment.

Let me know how this works out for you ;)

abjerner commented 5 years ago

Closing due to inactivity.