Facebook Graph API/SDK .NET - Get PageID of a Facebook user

1.2k Views Asked by At

I have a problem with Facebook Graph API/SDK .NET.
In my Website a user can log in with his Facebook-Account. I only want to have organizers of public Events to log on to this page.
But when a user logs in, I only get information about his own events, and that's the result I don't want. I want to get the evens of the Facebook-Page of a user (pages like clubs, associations, ...)
How can I get (if exists) a Facebook-Page where the logged in user is admin of, so that i can get events of this page?
Must a Facebook-Page have a 'real' user behind it or is it usual that the page is administrated without an admin user? Is there any way to get the information i want?

public ActionResult FBLogin()
{
    var fb = new FacebookClient();
    var loginUrl = fb.GetLoginUrl(new
    {
        client_id = "client_id",
        client_secret = "client_secret",
        redirect_uri = RedirectUri.AbsoluteUri,
        response_type = "code",
        scope = "user_events"
    });

    return Redirect(loginUrl.AbsoluteUri);
}

public ActionResult FBCallback(string code)
{
    var facebook = new FacebookClient();
    dynamic r = facebook.Post("oauth/access_token", new
    {
        client_id = "client_id",
        client_secret = "client_secret",
        redirect_uri = RedirectUri.AbsoluteUri,
        code = code
    });

    var accessToken = r.access_token;
    Session["AccessToken"] = accessToken;
    facebook.AccessToken = accessToken;
    dynamic me = facebook.Get("me/events");
    return null;
}

Thanks a lot!

1

There are 1 best solutions below

0
andyrandy On BEST ANSWER