Mercurial > altnet-hispano
diff Agendas/trunk/src/Agendas.Twitter/ITwitterAdapter.cs @ 158:734d3f0853bf
Manejando configuración de los publicadores con una sección propia en los .config
Agregando la opción de habilitar / deshabilitar un publicador
author | nelopauselli |
---|---|
date | Fri, 05 Aug 2011 16:55:18 -0300 |
parents | 0bca45e1e664 |
children |
line wrap: on
line diff
--- a/Agendas/trunk/src/Agendas.Twitter/ITwitterAdapter.cs Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Twitter/ITwitterAdapter.cs Fri Aug 05 16:55:18 2011 -0300 @@ -1,4 +1,5 @@ using System; +using AltNetHispano.Agendas.Configurations; using Twitterizer; namespace AltNetHispano.Agendas.Twitter @@ -7,11 +8,40 @@ { Uri BuildAuthorizationUri(string consumerKey, string consumerSecret, string callbackAddress); string GetAccessToken(string consumerKey, string consumerSecret, string requestToken, string verifier); - TwitterResponse<TwitterStatus> UpdateStatus(OAuthTokens tokens, string status); + bool Update(string status, out string message); } public class TwitterAdapter : ITwitterAdapter { + private static TwitterConfigurationElement _config; + + public TwitterAdapter() + { + _config = AgendasConfigurationManager.Publicadores.Twitter; + } + + private static string ConsumerKey + { + get { return _config.SendTwitter.ConsumerKey; } + } + + private static string ConsumerSecret + { + get { return _config.SendTwitter.ConsumerSecret; } + } + + + private static string AccessToken + { + get { return _config.SendTwitter.AccessToken; } + } + + + private static string AccessTokenSecret + { + get { return _config.SendTwitter.AccessTokenSecret; } + } + public Uri BuildAuthorizationUri(string consumerKey, string consumerSecret, string callbackAddress) { // Obtain a request token @@ -47,9 +77,21 @@ } - public TwitterResponse<TwitterStatus> UpdateStatus(OAuthTokens tokens, string status) + public bool Update(string status, out string message) { - return TwitterStatus.Update(tokens, status); + var tokens = new OAuthTokens + { + ConsumerKey = ConsumerKey, + ConsumerSecret = ConsumerSecret, + AccessToken = AccessToken, + AccessTokenSecret = AccessTokenSecret + }; + + var response = TwitterStatus.Update(tokens, status); + + message = response.ErrorMessage; + return response.Result == RequestResult.Success; + } } } \ No newline at end of file