How to Handle Facebook Application Requests?

前端 未结 6 1604
慢半拍i
慢半拍i 2021-01-05 08:05

I am working on a Facebook application And I am offering the user to invite his friend to the application using the C# SDK. as shown in Facebook documentation

My p

6条回答
  •  温柔的废话
    2021-01-05 08:34

    In case if you are using http://facebooksdk.codeplex.com/ with MVC3 at the app main page controller you should provide redirection for non-authorized users:

    var fbWebContext = FacebookWebContext.Current;
    if (fbWebContext.IsAuthorized() && fbWebContext.UserId > 0)
    {
        try
        {
            var fb = new FacebookWebClient(fbWebContext);
            dynamic result = fb.Get("/me");
        }
        catch (FacebookOAuthException)
        {
            var redirectString = string.Format("https://graph.facebook.com/oauth/authorize?client_id={0}&redirect_uri={1}&type=user_agent&display=page&scope={2}",
                                     Facebook.FacebookApplication.Current.AppId,
                                     FacebookWebContext.Current.Settings.CanvasPage,
                                     "email, publish_actions"
                                 );
            Response.Redirect("redirectString");
        }
    }
    

提交回复
热议问题