c#sdk让用户收到电子邮件

c#sdk让用户收到电子邮件

本文介绍了Facebook c#sdk让用户收到电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Facebook的网站进行认证。我想在用户注册时收集一些基本信息,包括他们的电子邮件地址。



我的登录代码是标准的:

  public ActionResult Login(string returnUrl)
{
var oAuthClient = new FacebookOAuthClient();
oAuthClient.AppId = AppSettings.GetConfigurationString(appId);
oAuthClient.RedirectUri = new Uri(AppSettings.GetConfigurationString(redirectUrl));
var loginUri = oAuthClient.GetLoginUrl(new Dictionary< string,object> {{state,returnUrl}});
return Redirect(loginUri.AbsoluteUri);
}

如何添加请求以访问权限?或者我做另一种方式吗?

解决方案

在sdk代码中的一个窥探,我想到了:

  public ActionResult Login(string returnUrl)
{
var oAuthClient = new FacebookOAuthClient();
oAuthClient.AppId = AppSettings.GetConfigurationString(appId);
oAuthClient.RedirectUri = new Uri(AppSettings.GetConfigurationString(redirectUrl));

var parameters = new Dictionary< string,object>();
参数[state] = returnUrl;
参数[scope] =email;

var loginUri = oAuthClient.GetLoginUrl(parameters);
return Redirect(loginUri.AbsoluteUri);
}

没有测试,小姐正在喊我工作迟到,所以会必须测试tomoz:)


I have a site which is using facebook for auth. I want to gather some basic info when a user signs up including their email address.

The code i have for the login is standard:

public ActionResult Login(string returnUrl)
    {
        var oAuthClient = new FacebookOAuthClient();
        oAuthClient.AppId = AppSettings.GetConfigurationString("appId");
        oAuthClient.RedirectUri = new Uri(AppSettings.GetConfigurationString("redirectUrl"));
        var loginUri = oAuthClient.GetLoginUrl(new Dictionary<string, object> { { "state", returnUrl } });
        return Redirect(loginUri.AbsoluteUri);
    }

How do i add the request to access permissions in that? Or do i do it another way?

解决方案

A snoop at the sdk code and i came up wiht:

 public ActionResult Login(string returnUrl)
    {
        var oAuthClient = new FacebookOAuthClient();
        oAuthClient.AppId = AppSettings.GetConfigurationString("appId");
        oAuthClient.RedirectUri = new Uri(AppSettings.GetConfigurationString("redirectUrl"));

        var parameters = new Dictionary<string, object>();
        parameters["state"] = returnUrl;
        parameters["scope"] = "email";

        var loginUri = oAuthClient.GetLoginUrl(parameters);
        return Redirect(loginUri.AbsoluteUri);
    }

not tested it yet and the missus is shouting at me for working late so will have to test tomoz :)

这篇关于Facebook c#sdk让用户收到电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 18:28