Обновленная версия клиента Facebook для dotNetOpenAuth - PullRequest
2 голосов
/ 16 июня 2011

Я обновил до последней версии 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 Ответ

2 голосов
/ 16 июня 2011

Если под «самым новым» вы подразумеваете CTP3 (4.0.0.11165), вы должны сначала знать, что известно, что не работает с Facebook, потому что Facebook реализует более старую версию OAuth 2.0.

Что касается прерывания сборки, то похоже, что вы либо компилируете файл DotNetOpenAuth.dll, который не включает поддержку OAuth 2.0. или по какой-то причине сборка не смогла разрешить ссылку. Ищите предупреждения выше об ошибках в журнале сборки.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...