Answered by:
facebook login dialogue issues on button click

Question
-
Hi all,
I am using below code to connect wid facebook. it is working well but dere are some issues.
- 1) when i login in 1st time then a its work well, but on 2nd time it auto loginin to facebook and also facebook login diaglog apperars for some second and then hide.
- 2) Second issue is that when i click on the signup button of facebook login dialogue then it open in seprate windows, i want it on the same window.
private void GetStatus()
{
var appId = "xxxxxxxxxxxxxxxxxxx";
string[] extendedPermissions = new[] { "publish_stream", "offline_access" };
var fbLoginDialog = new FacebookLoginDialog(appId, extendedPermissions);
fbLoginDialog.Focus();
fbLoginDialog.Activate();
this.Focus();
fbLoginDialog.ShowDialog(this);
if (fbLoginDialog.FacebookOAuthResult != null)
{
if (fbLoginDialog.FacebookOAuthResult.IsSuccess)
{
var fb = new FacebookClient(fbLoginDialog.FacebookOAuthResult.AccessToken);
dynamic result = fb.Get("/me");
var name = result.name;
}
else
{
MessageBox.Show(fbLoginDialog.FacebookOAuthResult.ErrorDescription);
}
}
}Facebook login dialoge class:
public partial class FacebookLoginDialog : Form
{
private Uri loginUrl;
public FacebookLoginDialog(string appId, string[] extendedPermissions)
{
var oauth = new FacebookOAuthClient { ClientId = appId };
var parameters = new Dictionary<string, object>
{
{ "response_type", "token" },
{ "display", "popup" }
};
if (extendedPermissions != null && extendedPermissions.Length > 0)
{
var scope = new StringBuilder();
scope.Append(string.Join(",", extendedPermissions));
parameters["scope"] = scope.ToString();
}
this.loginUrl = oauth.GetLoginUrl(parameters);
//loginForm.StartPosition = FormStartPosition.CenterParent;
//loginForm.ShowDialog(this);
//loginForm.Show(this);
InitializeComponent();
}
private void FacebookLoginDialog_Load(object sender, EventArgs e)
{
webBrowser.Navigate(this.loginUrl);
}
private void webBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
FacebookOAuthResult result;
if (FacebookOAuthResult.TryParse(e.Url, out result))
{
this.FacebookOAuthResult = result;
this.DialogResult = result.IsSuccess ? DialogResult.OK : DialogResult.No;
}
else
{
this.FacebookOAuthResult = null;
}
}
public FacebookOAuthResult FacebookOAuthResult { get; private set; }
}- Moved by Mike Dos Zhang Friday, February 17, 2012 9:12 AM http://facebooksdk.codeplex.com/ or http://developers.facebook.com/ (From:Windows Forms General)
Thursday, February 16, 2012 12:42 PM
Answers
-
Hi AhmadRock51,
According to your description, this question is about Fackbook SDKs which you can get better support in Facebook developers forum.
Sorry for any inconvenience this may cause.
Best Regards,
Bob Wu [MSFT]
MSDN Community Support | Feedback to us
- Proposed as answer by PressOnThis Saturday, February 25, 2012 10:41 PM
- Marked as answer by Mr. Wharty Friday, June 1, 2012 5:54 AM
Friday, February 17, 2012 9:47 AM
All replies
-
(You might have already done this, but I can't tell)
I'm a newbie at coding >.> But I'll try my best.
You can try making it so if its not at the login URL, then it won't show the MessageBox.
if(/* Url != LoginUrl */){
//don't show the message box
}
else{
//do show
}
- Proposed as answer by PressOnThis Thursday, February 16, 2012 10:40 PM
- Unproposed as answer by Mr. Wharty Friday, June 1, 2012 5:55 AM
Thursday, February 16, 2012 12:56 PM -
Hi AhmadRock51,
According to your description, this question is about Fackbook SDKs which you can get better support in Facebook developers forum.
Sorry for any inconvenience this may cause.
Best Regards,
Bob Wu [MSFT]
MSDN Community Support | Feedback to us
- Proposed as answer by PressOnThis Saturday, February 25, 2012 10:41 PM
- Marked as answer by Mr. Wharty Friday, June 1, 2012 5:54 AM
Friday, February 17, 2012 9:47 AM