从Facebook SDK v5.4迁移到alpha v6时出现问题 [英] Problems when migrating from Facebook SDK v5.4 to alpha v6

查看:72
本文介绍了从Facebook SDK v5.4迁移到alpha v6时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

登录后,我正在使用以下代码,该代码适用于5.4.1,但现在无法正常工作.

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
  }
}

我将FacebookOAuthClient迁移到FacebookClient,并且在迁移所有内容后都无法正常工作.

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

我的登录代码如下.我已经尝试了旧方法和新方法,但是都没有用.被注释的部分是我的旧版代码,该代码适用于5.4.您能帮我看看我在做什么错吗?

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();
//}

这是为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);

推荐答案

我建议您在 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);
    }

这篇关于从Facebook SDK v5.4迁移到alpha v6时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆