對不起,如果我再問這個問題,但我真的不能擺脫這個問題。我的應用程序我有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
展是你的代碼,否則我們不能幫助你.. – 8bitcat