简体   繁体   English

Facebook Graph API/SDK .NET - 获取 Facebook 用户的 PageID

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

I have a problem with Facebook Graph API/SDK .NET.我对 Facebook Graph API/SDK .NET 有问题。
In my Website a user can log in with his Facebook-Account.在我的网站中,用户可以使用他的 Facebook 帐户登录。 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, ...)我想获得用户的 Facebook 页面的事件(俱乐部、协会等页面)
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?如何获取(如果存在)登录用户是管理员的 Facebook 页面,以便我可以获取此页面的事件?
Must a Facebook-Page have a 'real' user behind it or is it usual that the page is administrated without an admin user? Facebook 主页必须有一个“真正的”用户支持,还是通常在没有管理员用户的情况下管理该页面? 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!非常感谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM