You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I manage a Facebook page and I with to get post on the site.
I'm able to get post putting in the page access token taken from Facebook Api Explorer, but this is not the good manner.
So by code, I'm able to get app token but not to get page token without pass fb auth page to get active auth token.
How to retrieve the posts by code?
My code:
FacebookOAuthClient client = new FacebookOAuthClient(appId, appSecret);
// Get an app token for the application (makes a call to the Facebook API)
Skybrud.Social.Facebook.Responses.Authentication.FacebookTokenResponse accessToken = client.GetAppAccessToken();
var service = Skybrud.Social.Facebook.FacebookService.CreateFromAccessToken(accessToken.Body.AccessToken);
Skybrud.Social.Facebook.Options.Posts.FacebookGetPostsOptions opt = new Skybrud.Social.Facebook.Options.Posts.FacebookGetPostsOptions()
{
Identifier = "xyz",
Fields = "id,name_with_location_descriptor,feed",
Limit = 20,
};
Skybrud.Social.Facebook.Options.Posts.FacebookGetPostsOptions opt2 = new Skybrud.Social.Facebook.Options.Posts.FacebookGetPostsOptions()
{
Identifier = "xyz",
Fields = "fields=id,name_with_location_descriptor,feed{message,created_time,name,full_picture,picture,story,description,from,likes}",
Limit = 20,
};
FacebookService facebookService = FacebookService.CreateFromAccessToken("access_token");
// Make the request to the API
FacebookGetPostsResponse responseFB = facebookService.Posts.GetPosts(opt2);
FacebookFieldsCollection fields = new FacebookFieldsCollection(
FacebookPostFields.Id,
FacebookPostFields.Message,
FacebookPostFields.Story,
FacebookPostFields.CreatedTime,
FacebookPostFields.From,
FacebookPostFields.Picture,
FacebookPostFields.Link
);
foreach (var post in responseFB.Body.Data)
{
// Write some of the account information to the output stream
<p>ID: @post.Id</p>
<p>Name: @post.Name</p>
<p>@post.Description</p>
<p>@post.CreatedTime</p>
<p>@post.Link</p>
FacebookGetPostResponse response = facebookService.Posts.GetPost(post.Id, fields);
FacebookPost postdata = response.Body;
<p>ID: @postdata.Id</p>
<p>Message: @postdata.Message</p>
<p>Story: @postdata.Story</p>
<p>Created: @postdata.CreatedTime</p>
<p>foto: @postdata.Picture</p>
<p>@postdata.Link</p>
@postdata.Likes
<hr />
}
The text was updated successfully, but these errors were encountered:
I manage a Facebook page and I with to get post on the site.
I'm able to get post putting in the page access token taken from Facebook Api Explorer, but this is not the good manner.
So by code, I'm able to get app token but not to get page token without pass fb auth page to get active auth token.
How to retrieve the posts by code?
My code:
The text was updated successfully, but these errors were encountered: