Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Handle Facebook Application Requests?

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 problem is when the friend of the user receive the application request and click Accept it does not show the application permission request page.

Do I need to preform any extra step to redirect the user to the application permission request page?

like image 861
Hiyasat Avatar asked Sep 12 '11 07:09

Hiyasat


2 Answers

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

like image 131
Hiyasat Avatar answered Oct 11 '22 08:10

Hiyasat


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");
    }
}
like image 40
Alexey Udovydchenko Avatar answered Oct 11 '22 07:10

Alexey Udovydchenko