1
var facebookClient = new FacebookClient
{
ClientIdentifier = "appId",
ClientSecret = "appSecret"
};
IAuthorizationState authorization = facebookClient.ProcessUserAuthorization();
if (authorization == null)
{
// Kick off authorization request
facebookClient.RequestUserAuthorization();
}
else
{
var request =
WebRequest.Create("https://graph.facebook.com/me?access_token=" +
Uri.EscapeDataString(authorization.AccessToken));
using (var response = request.GetResponse())
{
using (var responseStream = response.GetResponseStream())
{
var graph = FacebookGraph.Deserialize(responseStream);
lblFacebookUserName.Text = HttpUtility.HtmlEncode(graph.Name);
}
}
}
行至Facebook如何登錄使用DotNetOpenAuth
IAuthorizationState authorization = facebookClient.ProcessUserAuthorization();
總是返回null
注意,在DotNetOpenAuth.ApplicationBlock的新版本,ClientSecret不存在。它現在應該如下所示:FacebookClient fbClient = new FacebookClient {ClientIdentifier =「appId」, ClientCredentialApplicator = ClientCredentialApplicator.PostParameter(「appSecret」) }; – 2015-11-14 06:54:26