dotNetOpenAuth的Facebook客户端更新版本

时间:2011-06-15 22:35:26

标签: .net upgrade dotnetopenauth

我升级到最新版本的DotNetOpenAuth,我使用的是“DotNetOpenAuth.ApplicationBlock”,里面有facebook。

然而它不再编译,所以我想知道在哪里可以获得更新版本?

//-----------------------------------------------------------------------
// <copyright file="FacebookClient.cs" company="Andrew Arnott">
//     Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DotNetOpenAuth.ApplicationBlock {
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Web;
    using DotNetOpenAuth.Messaging;
    using DotNetOpenAuth.OAuth2;

    public class FacebookClient : WebServerClient {
        private static readonly AuthorizationServerDescription FacebookDescription = new AuthorizationServerDescription {
            TokenEndpoint = new Uri("https://graph.facebook.com/oauth/access_token"),
            AuthorizationEndpoint = new Uri("https://graph.facebook.com/oauth/authorize"),
        };

        /// <summary>
        /// Initializes a new instance of the <see cref="FacebookClient"/> class.
        /// </summary>
        public FacebookClient() : base(FacebookDescription) {
            this.AuthorizationTracker = new TokenManager();
        }
    }
}


//-----------------------------------------------------------------------
// <copyright file="FacebookGraph.cs" company="Andrew Arnott">
//     Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DotNetOpenAuth.ApplicationBlock.Facebook {
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Runtime.Serialization;
    using System.Runtime.Serialization.Json;
    using System.Text;

    [DataContract]
    public class FacebookGraph {
        private static DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(FacebookGraph));

        [DataMember(Name = "id")]
        public long Id { get; set; }

        [DataMember(Name = "name")]
        public string Name { get; set; }

        [DataMember(Name = "first_name")]
        public string FirstName { get; set; }

        [DataMember(Name = "last_name")]
        public string LastName { get; set; }

        [DataMember(Name = "link")]
        public Uri Link { get; set; }

        [DataMember(Name = "birthday")]
        public string Birthday { get; set; }

        [DataMember(Name = "email")]
        public string Email { get; set; }

        public static FacebookGraph Deserialize(string json) {
            if (String.IsNullOrEmpty(json)) {
                throw new ArgumentNullException("json");
            }

            return Deserialize(new MemoryStream(Encoding.UTF8.GetBytes(json)));
        }

        public static FacebookGraph Deserialize(Stream jsonStream) {
            if (jsonStream == null) {
                throw new ArgumentNullException("jsonStream");
            }
            return (FacebookGraph)jsonSerializer.ReadObject(jsonStream);
        }
    }
}


Error   3   The type or namespace name 'OAuth2' does not exist in the namespace 'DotNetOpenAuth' (are you missing an assembly reference?)   
Error   6   The type or namespace name 'WebServerClient' could not be found (are you missing a using directive or an assembly reference?)
Error   7   The type or namespace name 'AuthorizationServerDescription' could not be found (are you missing a using directive or an assembly reference?)    
Error   2   The type or namespace name 'Json' does not exist in the namespace 'System.Runtime.Serialization' (are you missing an assembly reference?)   
Error   4   The type or namespace name 'DataContractAttribute' could not be found (are you missing a using directive or an assembly reference?) 
Error   5   The type or namespace name 'DataContract' could not be found (are you missing a using directive or an assembly reference?)  
Error   8   The type or namespace name 'DataContractJsonSerializer' could not be found (are you missing a using directive or an assembly reference?)    

1 个答案:

答案 0 :(得分:2)

如果“最新”,你的意思是CTP3(4.0.0.11165),你应该首先知道已知用于Facebook,因为Facebook实现了旧版本的OAuth 2.0。

就构建中断而言,它看起来要么是针对不包含OAuth 2.0支持的DotNetOpenAuth.dll进行编译。或由于某种原因,构建无法解析引用。在构建日志中查找上面的警告