Facebook: get list of pages that a user is admin of using OAuth in ASP.NET MVC


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.


Asked by:- LuneAgile
0
: 2528 At:- 9/11/2018 2:46:00 PM
C# ASP.NET OAuth-login







2 Answers
profileImage Answered by:- manish

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.

 

0
At:- 9/12/2018 11:16:34 AM


profileImage Answered by:- LuneAgile

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.

0
At:- 9/12/2018 12:12:16 PM Updated at:- 9/12/2018 12:13:06 PM






Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use