Authentication Facebook C# SDK
I have a website where i have a event module, where the users can maintain their own events.
At the same time i have a Facebook Page(not app) and i would really like to create/update/delete the events from my website directly to Facebook.
I have the following working:
FacebookClient clientApp = new FacebookClient(token);
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("name", currentEvent.HeadLine);
Da开发者_如何学PythonteTime startTime = DateTime.Now;
DateTime endTime = DateTime.Now.AddDays(1);
parameters.Add("start_time", currentEvent.StartDateTime);
parameters.Add("end_time", currentEvent.EndDateTime);
parameters.Add("location", currentEvent.Location);
parameters.Add("description", currentEvent.Description);
var postResult = (IDictionary<string, object>)currentClient.Post("pageid/events", parameters);
the accesstoken used is from my facebook login, so if that expires the system fails.
Any other way or can i get a newer expiring accesstoken.
Regards Keld
regards Keld
You have two options, one is to request the permission offline access from Facebook when you obtain the token. This gives you a token that never expires (unless the user explicitly removes access for your app.
The second way is to handle exceptions from the callback of the method. In the handling code you detect a token expired exception and redirect users to the appropriate login page to get a new token. You can then re-try the event update.
精彩评论