もう一度この質問をすると申し訳ありませんが、私は本当にこの問題を取り除くことができません。私のアプリケーションでは2つのアカウントを取得し、1つでログインし、すべてが完璧です。いくつかのコンボボックスにアルバムとページをロードします。同じ情報を取得しようとして別のアカウントでログインしようとしますが、取得したアルバムとページは他のアカウントのもの。ログアウトするためにすべてを試しましたが、機能していません。私は尋ねませんが、私はたくさんのコードを読んで試しました!! ありがとう
ここで、ログアウトを「試行」します。
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