Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am using the following code after I login, which worked on 5.4.1, but now it isn't working as expected.

FacebookOAuthResult pResult;
if (m_pClient.TryParseOAuthCallbackUrl(e.Uri, out pResult))
{
  if (pResult.IsSuccess)
  {
    //handle if success
  }
  else
  {
  //handle if failed
  }
}

I migrated the FacebookOAuthClient to FacebookClient and after migrating everything this does not work.

My login code is as follows. I have tried both the old way and the new way, but both are not working. The commented portion is my legacy code that worked for 5.4 Can you please help me see what I am doing wrong?

//Dictionary<string, object> pParameters = new Dictionary<string, object> 
//{
// {"response_type", "token"},
// {"display", "touch"},
//};
//if ((extendedPermissions != null) && (extendedPermissions.Length > 0))
//{
// StringBuilder pScope = new StringBuilder();
// pScope.Append(string.Join(",", extendedPermissions));
// pParameters["scope"] = pScope.ToString();
//}

this is code added for v6

Uri pLoginUrl = m_pClient.GetLoginUrl(new { response_type = "token", display = "touch", scope = "publish_stream, offline_access", next = "https://www.facebook.com/connect/login_success.html" }); //also tried redirect_uri=""
m_pBrowser.Visibility = System.Windows.Visibility.Visible;
m_pBrowser.Navigate(pLoginUrl);
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
170 views
Welcome To Ask or Share your Answers For Others

1 Answer

I would recommend you look at the winforms sample at https://github.com/facebook-csharp-sdk/facebook-winforms-sample

    private Uri GenerateLoginUrl(string appId, string extendedPermissions)
    {
        dynamic parameters = new ExpandoObject();
        parameters.client_id = appId;
        parameters.redirect_uri = "https://www.facebook.com/connect/login_success.html";

        // The requested response: an access token (token), an authorization code (code), or both (code token).
        parameters.response_type = "token";

        // list of additional display modes can be found at http://developers.facebook.com/docs/reference/dialogs/#display
        parameters.display = "popup";

        // add the 'scope' parameter only if we have extendedPermissions.
        if (!string.IsNullOrWhiteSpace(extendedPermissions))
            parameters.scope = extendedPermissions;
        var fb = new FacebookClient();
        // when the Form is loaded navigate to the login url.
        return fb.GetLoginUrl(parameters);
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...