Is Skybrud the right tool for this job? I don't need to do any updates, or anything more fancy than just get the latest few posts. There will be links to encourage visitors to go to Facebook to see all posts.
I generated a Page Access Token using the Graph Api Explorer - but how do I do that in code? Or is this something that needs to be setup in Facebook?
I get the feeling that this is probably very simple, but I can't get my head around it at the moment!
If so, you can use the following code to fetch the 10 most recent posts of your Facebook page:
@using Skybrud.Social.Facebook
@using Skybrud.Social.Facebook.Objects.Posts
@using Skybrud.Social.Facebook.Options.Posts
@using Skybrud.Social.Facebook.Responses.Posts
@{
// Initialize a new service from an access token (user, page or app)
FacebookService service = FacebookService.CreateFromAccessToken("your access token");
// Make the request to the Facebook Graph API
FacebookPostsResponse response = service.Posts.GetPosts(new FacebookGetPostsOptions {
Identifier = "umbraco",
Fields = "created_time,message,id,picture",
Limit = 10
});
// Iterate through each post
foreach (FacebookPost post in response.Body.Data) {
// do something with the post
}
}
I can't remember exactly how page tokens work, and whether they expire (I think they might). But you can use what is called an app access token as long as the posts you wish to fetch is public. If you already have created a Facebook app, you can find the app access token on this page:
Not sure how to get started
I want to display the latest few (5 - 10?) posts from a Facebook page that I manage for a local club, on their website.
I played with Facebook's Graph Api Explorer and came up with
which gives me the basic data I need.
Is Skybrud the right tool for this job? I don't need to do any updates, or anything more fancy than just get the latest few posts. There will be links to encourage visitors to go to Facebook to see all posts.
I generated a Page Access Token using the Graph Api Explorer - but how do I do that in code? Or is this something that needs to be setup in Facebook?
I get the feeling that this is probably very simple, but I can't get my head around it at the moment!
Hi Gordon,
Since you write posts, wouldn't in more be like the
posts
endpoint rather thanfeed
?If so, you can use the following code to fetch the 10 most recent posts of your Facebook page:
I can't remember exactly how page tokens work, and whether they expire (I think they might). But you can use what is called an app access token as long as the posts you wish to fetch is public. If you already have created a Facebook app, you can find the app access token on this page:
https://developers.facebook.com/tools/accesstoken/
See, I said I didn't know where to start!
"If you already have created a Facebook app" - umm, I have created something, let's hope it's the right thing :-)
Thanks very much for the sample code.
is working on a reply...