本文整理汇总了C#中Facebook.FacebookClient.GetLoginUrl方法的典型用法代码示例。如果您正苦于以下问题:C# FacebookClient.GetLoginUrl方法的具体用法?C# FacebookClient.GetLoginUrl怎么用?C# FacebookClient.GetLoginUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Facebook.FacebookClient
的用法示例。
在下文中一共展示了FacebookClient.GetLoginUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Facebook
public ActionResult Facebook()
{
var fb = new FacebookClient();
Uri loginUrl;
if (Request.Url.AbsoluteUri == "http://localhost:53624/Account/Facebook")
{
loginUrl = fb.GetLoginUrl(new
{
client_id = "210504125641177",
client_secret = "d417ef6d72b9cdb430f938eb19c1b929",
redirect_uri = RedirectUri.AbsoluteUri,
response_type = "code",
scope = "user_birthday, email"
});
}
else
{
loginUrl = fb.GetLoginUrl(new
{
client_id = "118326544910444",
client_secret = "d2f09ce5b35cd32352d295be5df2ba39",
redirect_uri = RedirectUri.AbsoluteUri,
response_type = "code",
scope = "user_birthday, email"
});
}
return Redirect(loginUrl.AbsoluteUri);
}
示例2: Login
private async Task Login()
{
//Client ID of the Facebook App (retrieved from the Facebook Developers portal)
//Required permissions
var scope = "public_profile, email";
var redirectUri = WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString();
var fb = new FacebookClient();
var loginUrl = fb.GetLoginUrl(new
{
client_id = ClientId,
redirect_uri = redirectUri,
response_type = "token",
scope = scope
});
Uri startUri = loginUrl;
Uri endUri = new Uri(redirectUri, UriKind.Absolute);
#if WINDOWS_PHONE_APP
WebAuthenticationBroker.AuthenticateAndContinue(startUri, endUri, null, WebAuthenticationOptions.None);
#endif
#if WINDOWS_APP
WebAuthenticationResult result = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, startUri, endUri);
await ParseAuthenticationResult(result);
#endif
}
示例3: button1_Click
private void button1_Click(object sender, RibbonControlEventArgs e)
{
if (ThisAddIn.GetAccessToken() == "")
{
try
{
FacebookClient fc = new FacebookClient();
LoginForm l = new LoginForm(fc.GetLoginUrl(new
{
client_id = ThisAddIn._appkey,
response_type = "token",
display = "touch",
redirect_uri = "https://www.facebook.com/connect/login_success.html",
scope = String.Join(",", PERMISSIONS)
}).ToString(), this, true);
l.Show();
}
catch (Exception ex)
{
}
}
else
{
var fb = new FacebookClient(ThisAddIn.GetAccessToken());
dynamic me = fb.Get("me");
var url = me.link;
Process.Start(url);
}
}
示例4: FacebookLoginDialog
public FacebookLoginDialog(string appId, string extendedPermissions)
{
if (string.IsNullOrEmpty(appId))
throw new ArgumentNullException("appId");
var fb = new FacebookClient();
IDictionary<string, object> loginParameters = new Dictionary<string, object>();
loginParameters["client_id"] = appId;
loginParameters["redirect_uri"] = "https://www.facebook.com/connect/login_success.html";
// The requested response: an access token (token), an authorization code (code), or both (code token).
loginParameters["response_type"] = "token";
// list of additional display modes can be found at http://developers.facebook.com/docs/reference/dialogs/#display
loginParameters["display"] = "popup";
// add the 'scope' parameter only if we have extendedPermissions.
if (!string.IsNullOrEmpty(extendedPermissions))
{
// A comma-delimited list of permissions
loginParameters["scope"] = extendedPermissions;
}
// when the Form is loaded navigate to the login url.
_loginUrl = fb.GetLoginUrl(loginParameters);
InitializeComponent();
}
示例5: AuthenticateFacebookAsync
private async Task<string> AuthenticateFacebookAsync()
{
try
{
var fb = new FacebookClient();
var loginUri = fb.GetLoginUrl(new
{
client_id = AppId,
redirect_uri = FbSuccess,
scope = ExtendedPermissions,
display = "popup",
response_type = "token"
});
var authenticationResult =
await
FacebookAuthenticationBroker.AuthenticateAsync(loginUri);
return ParseAuthenticationResult(authenticationResult);
}
catch (Exception ex)
{
return ex.Message;
}
}
示例6: Connect
public ActionResult Connect(string returnUrl)
{
// TODO: Rebuild functionality using CoffeeScript implementation and new C# API
var fb = new FacebookClient();
var loginUri = fb.GetLoginUrl(new { state = returnUrl });
return Redirect(loginUri.AbsoluteUri);
}
示例7: Facebook
private async Task<string> Facebook()
{
try
{
var fb = new FacebookClient();
var redirectUri = WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString();
var loginUri = fb.GetLoginUrl(new
{
client_id = AppId,
redirect_uri = redirectUri,
scope = ExtendedPermissions,
display = "popup",
response_type = "token"
});
var callbackUri = new Uri(redirectUri, UriKind.Absolute);
var authenticationResult =
await
WebAuthenticationBroker.AuthenticateAsync(
WebAuthenticationOptions.None,
loginUri, callbackUri);
return ParseAuthenticationResult(fb, authenticationResult);
}
catch (Exception)
{
throw;
}
}
示例8: FacebookLoginPage
public FacebookLoginPage()
{
// NOTE: make sure to enable scripting for the web browser control.
// <phone:WebBrowser x:Name="webBrowser1" IsScriptEnabled="True" />
var fb = new FacebookClient();
var loginParameters = new Dictionary<string, object>();
loginParameters["client_id"] = AppId;
loginParameters["redirect_uri"] = RedirectUri;
// The requested response: an access token (token), an authorization code (code), or both (code token).
// note: there is a bug in wpf browser control which ignores the fragment part (#) of the url
// so we cannot get the access token. To fix this, set response_type to code as code is set in
// the querystring.
loginParameters["response_type"] = "code";
// add the 'scope' parameter only if we have extendedPermissions.
if (!string.IsNullOrEmpty(ExtendedPermissions))
{
// A comma-delimited list of permissions
loginParameters["scope"] = ExtendedPermissions;
}
// when the Form is loaded navigate to the login url.
_loginUrl = fb.GetLoginUrl(loginParameters);
InitializeComponent();
}
示例9: Login
public void Login()
{
dynamic parameters = new ExpandoObject();
parameters.client_id = "781659158605315";
parameters.redirect_uri = "https://www.facebook.com/connect/login_success.html";
parameters.response_type = "token";
parameters.display = "popup";
var fb = new FacebookClient();
Uri loginUrl = fb.GetLoginUrl(parameters);
var urlWithScope = loginUrl.AbsoluteUri + "&scope=user_friends";
webBrowserLogin.Navigate(urlWithScope);
}
示例10: Facebook
// GET: /Account/
public ActionResult Facebook()
{
var fb = new FacebookClient();
var loginUrl = fb.GetLoginUrl(new {
client_id = "100106430186046",
client_secret = "7c9ee3c7e3a1362098ad88b7a9227fc8",
redirect_uri = RedirectUri.AbsoluteUri,
response_type = "code",
scope = "email" // Add other permissions as needed
});
return Redirect(loginUrl.AbsoluteUri);
}
示例11: Facebook
public ActionResult Facebook()
{
var fb = new FacebookClient();
var loginUrl = fb.GetLoginUrl(new
{
client_id = "769429839779017",
client_secret = "910688593eef875bfca0e70767032c0d",
redirect_uri = RedirectUri.AbsoluteUri,
response_type = "code",
scope = "email"
});
return Redirect(loginUrl.AbsoluteUri);
}
示例12: GenerateLoginUrl
public string GenerateLoginUrl()
{
dynamic parameters = new ExpandoObject();
parameters.client_id = ApplicationId;
parameters.redirect_uri = "https://www.facebook.com/connect/login_success.html";
parameters.response_type = "token";
parameters.display = "popup";
fb = new FacebookClient();
Uri loginUri = fb.GetLoginUrl(parameters);
return loginUri.AbsoluteUri;
}
示例13: Facebook
public ActionResult Facebook()
{
var fb = new FacebookClient();
var loginUrl = fb.GetLoginUrl(new
{
client_id = "462931197153588",
client_secret = "82c4ec01d4516d06889341aed8857e5b",
redirect_uri = RedirectUri.AbsoluteUri,
response_type = "code",
scope = "email" // Add other permissions as needed
});
return Redirect(loginUrl.AbsoluteUri);
}
示例14: AuthenFacebook
public ActionResult AuthenFacebook()
{
var fb = new FacebookClient();
var loginUrl = fb.GetLoginUrl(new
{
client_id = ConfigurationManager.AppSettings["clientId"],
//"412367302292593",
client_secret = ConfigurationManager.AppSettings["clientSecret"],
//"95b9b97174f94bbff3bdff437e520cc7",
redirect_uri = RedirectUri.AbsoluteUri,
response_type = "code",
scope = "email,user_birthday,user_about_me,user_website" // Add other permissions as needed
});
return Redirect(loginUrl.AbsoluteUri);
}
示例15: Index
//
// GET: /Facebook/
public ActionResult Index()
{
if (Session["AccessToken"] != null && !string.IsNullOrEmpty(Session["AccessToken"].ToString()))
return RedirectToAction("Home");
var fb = new FacebookClient();
var loginUrl = fb.GetLoginUrl(new
{
client_id = ConsumerKey,
client_secret = ConsumerSecret,
redirect_uri = "http://userprofiler.azurewebsites.net/facebook/Callback",
response_type = "code",
scope = "email"
});
return Redirect(loginUrl.AbsoluteUri);
}