How to Handle Facebook Application Requests?

前端 未结 6 1575
慢半拍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");
        }
    }
    
    0 讨论(0)
  • 2021-01-05 08:34

    You need to ask the user for the permission as seen on http://developers.facebook.com/docs/reference/dialogs/oauth/ . How did you get the permissions of the first user who is inviting the friend? You can redirect him to that page or the page which handles the app request clicks can check the application permissions. If the user doesn't grant a permission, you will easily ask him for them.

    You should always check the permissions, because even the user already using your application can revoke them.

    0 讨论(0)
  • 2021-01-05 08:43

    i found the solution

    i start ask for permission on my application canvas page and if user accept, redirect to the same page with query string. not perfect solution but it works fine

    0 讨论(0)
  • 2021-01-05 08:43

    you should check if the user is accesing your app from a request... if the request_ids parameter is present. If so you should redirect the user to a page where permissons would be asked and a list of outstanding requests shown!

    0 讨论(0)
  • 2021-01-05 08:45

    By default, accepting a Facebook application request redirects a user to the application's main page. If your application requires Facebook permissions to view the main page, you would want to check that all visitors have accepted your permissions and redirect them to the OAuth permissions dialog if they have not. Note that's Facebook documentation suggests deleting the accepted request after the user visits your application, through the request_ids parameter that is sent in the query string.

    0 讨论(0)
  • 2021-01-05 08:49

    What do you mean by application permission request page ? Is that the one where the user authorizes the third party application to access his facebook data?

    I agree with the other answer. After a user clicks the app request notification icon from within his facebook account he gets redirected to the application's canvas page, the request includes a list of the request_ids generated by your application

    Within your application, after reading the facebook request_ids, you can request facebook about the received request_ids and then decide what to do with that information, you can pass an additional data parameter in order to provide extra information about how was the app request generated.

    Finally you can redirect the user to whatever page you want based on the information that you got.

    Hope this helps

    0 讨论(0)
提交回复
热议问题