How to Handle Facebook Application Requests?

╄→гoц情女王★ 提交于 2019-11-30 20:03:44

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

user942217

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");
    }
}

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.

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.

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

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!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!