Facebook的登录的Windows Phone 8.1 [英] Facebook Login for Windows Phone 8.1

查看:236
本文介绍了Facebook的登录的Windows Phone 8.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出从一款Windows Phone 8.1的应用程序(C#)的Facebook是日志的简单的代码。

I am trying to figure out a simple code for logging in facebook from a Windows Phone 8.1 app (C#).

由于的Facebook客户端从的NuGet不达标的Windows Phone 8.1,看来我不得不写一些额外的代码。正如我在Facebook发布读取的 ,我需要推出一个开放的调用登录对话框。说多了,我能够做到:

As the Facebook Client from NuGet doesn't target Windows Phone 8.1, it seems I'd have to write some extra code. As I read in this facebook post, I'd need to launch an Uri to invoke the Login Dialog. That much, I managed to do :

 await Launcher.LaunchUriAsync(FacebookUri.DisplayLoginDialog);

其中DisplayLoginDialog是对请求(APPID,productId参数,权限所需要的必要的数据静态字符串对象等)。我被重定向到Facebook的应用程序,接受我的应用程序需要这样的权限。

where DisplayLoginDialog is a static string object with the required necessary data on the request (appId, productId, permissions, etc). I was redirected to the facebook app, to accept that my app requires such permissions.

和我接受了。

所以,现在怎么办?我如何得到一个回应什么的的access_token ?我已经研究了很多关于这一点,但我没能找到相关的帖子。

So what now? How do I get a response or something with the access_token? I have researched a lot for this but I wasn't able to find relevant posts.

从上面同样的Facebook链接,称在部分的处理登录对话框是:

The same facebook link from above, says at the section of Handling the Login Dialog that :


如果有人成功登录,您的应用程序的URI关联将被自动触发,这意味着他们将被发送到你的应用程序,与访问令牌一起:

msft-{ProductID}://authorize/?
access_token={user-access-token}&
expires_in={expiration-time-of-token}



但我对如何迷惑在C#中实际使用此。

But I am confused on how to actually use this in C#.

我如何获得与访问令牌的响应错误代码错误信息如果它失败了,就像是写在Facebook发布?

How do I get a response with the access token after the login suceeded or and error code and error message if it failed, like it is written in the facebook post?

推荐答案

在Package.appxmanifest文件,请转到声明选项卡,然后添加一个协议声明。

In the Package.appxmanifest file, go to 'Declarations' Tab and add a Protocol Declaration.

在名称字段中输入您的Microsoft产品ID为MSFT-PRODUCT_ID[产品没有破折号ID。

In the Name Field, enter your Microsoft product id as 'msft-PRODUCT_ID' [product id without dashes].

在App.xaml.cs文件中,添加以下代码

In the App.xaml.cs file, add the following code

    protected override void OnActivated(IActivatedEventArgs args)
    {
        if (args.Kind == ActivationKind.Protocol)
        {
            ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs;

            Uri responseUri = eventArgs.Uri;

           //Now you can use responseUri to retrieve the access token and expiration time of token

        }

        base.OnActivated(args);
    }

这篇关于Facebook的登录的Windows Phone 8.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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