Hi, I have added login with facebook button using OAuth in my MVC project, now I want to get list of all the pages,while user is logging in, of which user is admin, here is the link which shows method to get list of pages that a user is admin of
But I would like to know to get the pages while logging in using ASP.NET MVC C#
Thanks.
You have already mentioned way to get user pages of which he/she is admin of, so to fetch it detials just after logging in using facebook, you can call thefacebook login success ActionMethod in the controller and then send request to faceboook pages api using C#.
But before calling graph API you need to get facebook access token, for that
Go to developer.facebook.com -> Tools & Support -> Select Graph API Explorer
Here you get FQL Query, Access Token, then in C# ActioMethod(called after user is successfully logged in using fb)
var client = new FacebookClient();
client.AccessToken = Your Access Token;
//show user's profile picture
dynamic me = client.Get("me?fields=picture");
pictureBoxProfile.Load(me.picture.data.url);
//get pages details
here is the FacebookClient SDK link https://github.com/facebook-csharp-sdk/facebook-csharp-sdk
Some more reference link
https://piotrgankiewicz.com/2017/02/06/accessing-facebook-api-using-c/
https://developers.facebook.com/docs/graph-api/reference/page/
You just need to get access token and call facebook api with proper url to get pages details.
Hi, manish Thanks. but still not know how can stored list pages facebook who user is admin of.
In your method :
var client = new FacebookClient();
client.AccessToken = Your Access Token;
//show user's profile picture
dynamic me = client.Get("me?fields=picture");
pictureBoxProfile.Load(me.picture.data.url);
//get pages details
here in this part how I can get the details pages ? maybe that
var client = new FacebookClient();
client.AccessToken = Your Access Token;
//show user's Pages that he admin of
dynamic me = client.Get("me/accounts");
// how can show those pages in view ???
Please if this is correct how can show those pages inside view, Thanks.
here is a example for retrieve posts but I don't know how can make seem thing with list pages that user admin of .
https://stackoverflow.com/questions/36283007/reading-facebook-post-in-mvc/36373853#36373853.
Thanks in advance.
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly