Hi. I'm using graph api to get posts and comments from facebook page. But I want get the new posts or new comments. Means want to refresh the data coming from graph api.
Is there any way to do that in ASP.NET MVC? Thanks.
Yes Possible, using hangfire also, it is called Recurring jobs, you need to set a method in a hangfire to call it periodically.
Read this article https://qawithexperts.com/article/asp.net/background-jobs-in-aspnet-mvc-c-using-hangfireio/102 for more details about hangfire in asp.net/C#
You can fetch new data from api by periodically calling api
$(document).ready(function() {
// SET AUTOMATIC call to function for 5000 MILISECONDS (5 SECONDS).
setInterval('getNewPostsComments()', 5000);
});
function getNewPostsComments(){
//Call server side method using AJAX
//or Call api using Javascript
//append new data
}
Whether you are pulling data from Server side C# code or front end code using javascript, from graph api, you can periodically call the function using AJAX to fetch data from api and if there are new posts or comments append it in your html code.
Hi, Thanks, how can we do that using HangFire background jobs. to continuously look for new posts and comments I'm using code asp.net core2 to retrieve posts ans comments from graph api .
private List<posts> fbRetrievePosts(String Url, String AccessToken)
{
//
}
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly