C#Facebook sdk 6.1.4注销

时间:2013-01-01 17:36:17

标签: facebook-c#-sdk

很抱歉,如果我再次提出这个问题,但我真的无法摆脱这个问题。我的应用程序我有2个帐户,我登录一个,一切都很完美我在一些组合框中加载专辑和页面,我尝试登录另一个帐户试图获取相同的信息,但我得到的专辑和页面混合了其他帐户。我尝试了所有注销,但没有工作。我会问,但我读了并尝试了这么多代码!感谢

这是我“尝试”注销的地方:

    private void button2_Click_1(object sender, EventArgs e)
    {
        comboBox1.Items.Clear();
        comboBox3.Items.Clear();

        //var fb = new FacebookClient();
        //var logoutUrl = fb.GetLogoutUrl(new { access_token = this.AccessToken, next = "https://www.facebook.com/connect/login_success.html" });
        //webBrowser_01.Navigate(logoutUrl);

        logout = "ok";

        var fb = new FacebookClient();
        var logoutUrl = fb.GetLogoutUrl(new { access_token = this.AccessToken, next = "https://www.facebook.com/connect/login_success.html" });

        webBrowser_01.Navigate(logoutUrl);
    }

这是我加载数据的地方:

     private void WebBrowserNavigated(object sender, WebBrowserNavigatedEventArgs e)
    {
        if(logout.Trim().Length==0)
        {

        // get token
        var url = e.Url.Fragment;
        if (url.Contains("access_token") && url.Contains("#"))
        {
            //this.Hide();
            url = (new Regex("#")).Replace(url, "?", 1);

            this.AccessToken = System.Web.HttpUtility.ParseQueryString(url).Get("access_token");

            //MessageBox.Show(this.AccessToken);

            fb = new FacebookClient(this.AccessToken);
            fb.PostCompleted += new EventHandler<FacebookApiEventArgs>(fb_PostCompleted);



            //ALBUM BEST

            //Get the album data

            dynamic albums = fb.Get("me/albums");
            foreach (dynamic albumInfo in albums.data)
            {
                //Get the Pictures inside the album this gives JASON objects list that has photo attributes 
                // described here http://developers.facebook.com/docs/reference/api/photo/
                //dynamic albumsPhotos = fb.Get(albumInfo.id + "/photos");
                string jdata = albumInfo.ToString();
                JObject obj = JObject.Parse(jdata);
                string aid = (string)obj["id"];
                string coverphoto = (string)obj["cover_photo"];
                string name = (string)obj["name"];
                //MessageBox.Show(aid + " - " + name);

                Albums_Name[name] = aid;
            }


            //ROUTINE PER INDIVIDUARE LE PAGES

            dynamic All_Accounts = fb.Get("me/accounts");
            foreach (dynamic accountInfo in All_Accounts.data)
            {
                //Get the Pictures inside the album this gives JASON objects list that has photo attributes 
                // described here http://developers.facebook.com/docs/reference/api/photo/
                //dynamic albumsPhotos = fb.Get(albumInfo.id + "/photos");
                string jdata = accountInfo.ToString();
                JObject obj = JObject.Parse(jdata);
                string aid = (string)obj["id"];
                string name = (string)obj["name"];
                Access_Token_Pages = (string)obj["access_token"];
                //MessageBox.Show(aid + " - " + name + " - " + Access_Token_Pages);
                Accounts_Name[name] = aid;

            }



            comboBox1.Items.Clear();
            //comboBox2.Items.Clear();
            comboBox3.Items.Clear();



            foreach (DictionaryEntry element in Albums_Name)
            {
                if (element.Key.ToString().IndexOf(@"Timeline Photos") == -1 && element.Key.ToString().IndexOf(@"Mobile Uploads") == -1 && element.Key.ToString().IndexOf(@"Profile Pictures") == -1)
                {
                    comboBox1.Items.Add((string)element.Key);
                }
            }

            comboBox1.SelectedIndex = comboBox1.FindStringExact(Default_Album);


            //ROUTINE PER INDIVIDUARE GLI ALBUM DELLE PAGES
            fb2 = new FacebookClient(Access_Token_Pages);
            fb2.PostCompleted += new EventHandler<FacebookApiEventArgs>(fb_PostCompleted);

            foreach (DictionaryEntry element in Accounts_Name)
            {
                //MessageBox.Show((string)element.Value);
                dynamic Pages_Albums = fb2.Get((string)element.Value + "/albums");
                foreach (dynamic albumInfo in Pages_Albums.data)
                {
                    //Get the Pictures inside the album this gives JASON objects list that has photo attributes 
                    // described here http://developers.facebook.com/docs/reference/api/photo/
                    //dynamic albumsPhotos = fb.Get(albumInfo.id + "/photos");
                    string jdata = albumInfo.ToString();
                    JObject obj = JObject.Parse(jdata);
                    string aid = (string)obj["id"];
                    //string coverphoto = (string)obj["cover_photo"];
                    string name = (string)obj["name"];
                    //MessageBox.Show(aid + " - " + name);

                    All_Pages_Album[name] = aid;
                }

            }

            foreach (DictionaryEntry element in All_Pages_Album)
            {

                comboBox3.Items.Add((string)element.Key);
            }

            comboBox3.SelectedIndex = comboBox3.FindStringExact(Default_Pages_Album);

        }

    }

    } 

    Thanks  

1 个答案:

答案 0 :(得分:0)

这是由2个原因引起的问题。 .net浏览器/ ie和facebooks从不工作注销功能。

当用户从facebook退出或完成工作时,您必须编写第二个杀死并打开原始软件的软件。没有杀死它的可执行webbrowser控件永远不会死:)并且previos用户会话无论如何都会保持活跃。

另外,对于facebook注销禁用cookie,除了正在访问的网站,即...你必须查找该设置