Facebook .NET客户端SDK是否支持通过AppStudio生成的通用应用程序/应用程序?

我通过微软的AppStudio创建了一个通用应用程序。 我尝试按照“美味教程”( http://facebooksdk.net/docs/phone/tutorial/ )向应用添加Facebook身份validation。

当我在手机上运行应用程序时,我永远无法访问facebook登录页面,因为以下行: await App.FacebookSessionClient.LoginAsync("user_about_me,read_stream");

总是会导致以下exception:

System.NotImplementedException: Not implemented
at Windows.Security.Authentication.Web.WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions options, Uri requestUri, Uri callbackUri) at Facebook.Client.FacebookSessionClient.d__24.MoveNext()

exception的来源是在FacebookSessionClient.csfacebook-client软件包 )中的这个调用: var result = await WebAuthenticationBroker.AuthenticateAsync(options, startUri, endUri);

似乎这个function没有为手机实现。 我仍然想知道turial是如何可能的,它引用完全相同的代码将起作用。

它尚未实现8.1。 如果要在8.1中使用Facebook身份validation,可以使用以下方法:

在您的App类中:

 private const string RedirectUrl = "https://www.facebook.com/connect/login_success.html"; private static readonly IReadOnlyCollection Permissions = new[] { "email", "offline_access" }; protected override void OnActivated(IActivatedEventArgs args) { base.OnActivated(args); var continuationActivatedEventArgs = args as IContinuationActivatedEventArgs; if (continuationActivatedEventArgs == null) return; var webAuthenticationResult = ((WebAuthenticationBrokerContinuationEventArgs)continuationActivatedEventArgs).WebAuthenticationResult; if (webAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success) { var facebookClient = new FacebookClient(); var result = facebookClient.ParseOAuthCallbackUrl(new Uri(webAuthenticationResult.ResponseData)); if (!result.IsSuccess) { // Process unsuccessful authentication } else { // Process successful authentication var accessToken = result.AccessToken; } } } // Authentication method, this method should be invoked when you click Facebook authentication button public void AuthenticateAndContinue() { var loginUrl = GetLoginUrl(); WebAuthenticationBroker.AuthenticateAndContinue(loginUrl, new Uri(RedirectUrl)); } private Uri GetLoginUrl() { var parameters = new Dictionary(); parameters["client_id"] = "YourFacebookApplicationId"; parameters["redirect_uri"] = RedirectUrl; parameters["response_type"] = "token"; parameters["display"] = "touch"; parameters["mobile"] = true; parameters["scope"] = String.Join(",", Permissions); var facebookClient = new FacebookClient(); return facebookClient.GetLoginUrl(parameters); } 

我把所有东西放在一个地方仅仅是为了示例目的,最好将fb认证逻辑分开。 你可以在这里找到这种方法MSDN Windows Phone 8.1 Web身份validation示例