2013-01-01 162 views
0

對不起,如果我再問這個問題,但我真的不能擺脫這個問題。我的應用程序我有2個帳戶,我登錄一個,一切都很完美我加載相冊和一些組合框中的頁面,我嘗試登錄另一個帳戶試圖獲取相同的信息,但我得到的專輯和頁面與其他帳戶的。我嘗試了一切註銷,但沒有工作。我would.t問,但我閱讀並嘗試了這麼多的代碼!由於C#Facebook的SDK 6.1.4註銷

這裏就是我 「嘗試」 登出:

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

展是你的代碼,否則我們不能幫助你.. – 8bitcat

回答

0

這是問題2個原因造成的。 .net瀏覽器/ ie和facebook從不工作註銷功能。

當用戶從Facebook註銷或完成他的工作時,您必須編寫第二個軟件來殺死並打開您的原始軟件。不殺死它的可執行webbrowser控件永遠不會死:)而且previos用戶會話保持活着,不管是什麼。

還爲除網站Facebook註銷停用Cookie在IE中被訪問......你要查找該設置

+0

測試非常好!有時候它不起作用,用戶的Facebook帳戶會混淆並導致問題。我試過你的解決方案...使用你的解決方案...並失敗了 – erichste

+0

嗯,我嘗試了很多解決方案,但我發佈的作品,當你註冊你的應用程序(在FB開發者),你必須選擇一個「應用程序域」它將由Facebook本身提供,就像我的「https://glacial-beyond-3099.herokuapp.com/」,我嘗試了很多,它的工作原理。 – user1941286