0

对不起,如果我再次问这个问题,但我真的无法摆脱这个问题。我的应用程序我有 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  
4

1 回答 1

0

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

您必须编写第二个软件,当用户从 facebook 注销或完成他的工作时,该软件会杀死并打开您原来的软件。如果不杀死其可执行的 webbrowser 控件,它就永远不会消失 :) 无论如何,previos 用户会话都会保持活动状态。

此外,对于 facebook 注销禁用 cookie,除了在 ie 中访问的网站...您必须查找该设置

于 2013-01-06T03:14:24.490 回答