在WP7中使用facebook c#sdk从Facebook登出 [英] Logging out from facebook using facebook c# sdk in WP7

查看:205
本文介绍了在WP7中使用facebook c#sdk从Facebook登出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Windows Phone应用程序中使用Facebook C#sdk从Facebook实现注销



我的主要问题是我们如何使用WP7中的Facebook C#SDK注销



我发现这篇文章在搜索



文章链接



他正在试图找到使用正则表达式注销url,但是在我的应用程序中没有工作



当我尝试浏览器浏览的事件进入无限循环



您可以在Windows Phone 7中分享与facebook注销相关的任何样品/帖子。



我想要注销应该发生在用户干预之后,点击在一个按钮上,他应该从Facebook上溜出去,下一次他应该看到登录页面



我也尝试过以下帖子/博客,但没有用。





LINK 2 在分配accesstoken时出现错误



更新



LogOutButtonCode

  FacebookClient _fbClient = new FacebookClient(fbaccess.AccessToken); 
var logoutParams = new Dictionary< string,object>();
logoutParams.Add(next,https://www.facebook.com/connect/login_success.html);
//logoutParams.Add(,)

var logoutUrl = _fbClient.GetLogoutUrl(logoutParams);
BrowserControl.Navigated + = new EventHandler< System.Windows.Navigation.NavigationEventArgs>(BrowserControl_Navigated);

BrowserControl.Navigate(new Uri(logoutUrl.AbsoluteUri));

导航事件代码

  if(e.Uri.AbsoluteUri ==https://www.facebook.com/connect/login_success.html)
{


NavigationService.Navigate(new Uri(/ MainPage.xaml,UriKind.Relative));
}

e.Uri.AbsoluteUri返回 https:// www.facebook.com/home.php



注销URL我从服务器得到 https:// www .facebook.com / logout.php?next = https://www.facebook.com/connect/login_success.html

解决方案

使用 FacebookClient.Logout 生成注销网址。



这是代码段来自 winforms示例,这将在wp7中进行一些修改。

  private void btnLogout_Click(object sender,EventArgs e)
{
var fb = new FacebookClient();

var logoutUrl = fb.GetLogoutUrl(new
{
next =https://www.facebook.com/connect/login_success.html,
access_token = _accessToken
});
var webBrowser = new WebBrowser();
webBrowser.Navigated + =(o,args)=>
{
if(args.Url.AbsoluteUri ==https://www.facebook.com/connect/login_success.html)
关闭();
};

webBrowser.Navigate(logoutUrl.AbsoluteUri);
}

确保在登录时保存访问令牌,因为它需要登出。


I want to implement logout from facebook using facebook C# sdk in my windows phone app

My primary question is how do we logout using Facebook C# SDK in WP7

I found this article in search

Article link

there he is trying to find the logout url using regex, but that did not working in my app

when i try that the browser navigated event is going into infinite loop

you can share any samples/posts related to facebook logout in windows phone 7.

I want logout should happen with out user intervention, after he clicks on a button he should looged out from facebook and from next time he should see the login page

I tried following posts/blogs also but no use.

LINK 1

LINK 2 this giving error while splitting the accesstoken

UPDATE

LogOutButtonCode

 FacebookClient _fbClient = new FacebookClient(fbaccess.AccessToken);
        var logoutParams = new Dictionary<string, object>();
        logoutParams.Add("next", "https://www.facebook.com/connect/login_success.html");
        //logoutParams.Add("",)

        var logoutUrl = _fbClient.GetLogoutUrl(logoutParams);
        BrowserControl.Navigated += new EventHandler<System.Windows.Navigation.NavigationEventArgs>(BrowserControl_Navigated);

        BrowserControl.Navigate(new Uri(logoutUrl.AbsoluteUri));

Navigated Event CODE

if (e.Uri.AbsoluteUri == "https://www.facebook.com/connect/login_success.html")
        {


            NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
        }

e.Uri.AbsoluteUri returns https://www.facebook.com/home.php

Logout URL i am getting from the server https://www.facebook.com/logout.php?next=https://www.facebook.com/connect/login_success.html

解决方案

Use FacebookClient.Logout to generate the logout url.

This is the snippet from winforms sample which will work in wp7 with some modifications.

    private void btnLogout_Click(object sender, EventArgs e)
    {
        var fb = new FacebookClient();

        var logoutUrl = fb.GetLogoutUrl(new
                                            {
                                                next = "https://www.facebook.com/connect/login_success.html",
                                                access_token = _accessToken
                                            });
        var webBrowser = new WebBrowser();
        webBrowser.Navigated += (o, args) =>
                                    {
                                        if (args.Url.AbsoluteUri == "https://www.facebook.com/connect/login_success.html")
                                            Close();
                                    };

        webBrowser.Navigate(logoutUrl.AbsoluteUri);
    }

Make sure to persist the access token somewhere when you login as it is required to logout.

这篇关于在WP7中使用facebook c#sdk从Facebook登出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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