view Agendas/trunk/src/Agendas.Twitter/oAuthTwitter.cs @ 302:11dddcc9a862 tip

Historico de Eventos, no muestra bien la Url del Patrocinador.
author juanjose.montesdeocaarbos
date Tue, 14 Aug 2012 21:54:30 -0300
parents a7420f05716a
children
line wrap: on
line source

using System;
using System.Collections.Generic;
using System.Web.Script.Serialization; 
using AltNetHispano.Agendas.Configurations;

namespace AltNetHispano.Agendas.Twitter
{
	public class OAuthTwitter
	{
		private readonly ITwitterAdapter _twitterAdapter;

		public OAuthTwitter()
		{
			_twitterAdapter = new TwitterAdapter();
		}

		public OAuthTwitter(ITwitterAdapter twitterAdapter)
		{
			_twitterAdapter = twitterAdapter;
		}

		private string ConsumerKey
		{
			get { return AgendasConfigurationManager.Publicadores.Twitter.SignIn.ConsumerKey; }
		}

		private string ConsumerSecret
		{
			get { return AgendasConfigurationManager.Publicadores.Twitter.SignIn.ConsumerSecret; }
		}

		public Uri AuthorizationLinkGet(string callbackAddress)
		{
			var request = _twitterAdapter.BuildAuthorizationUri(ConsumerKey, ConsumerSecret, callbackAddress);
			return request;
		}

		public string AccessTokenGet(string requestToken, string verifier)
		{
			return _twitterAdapter.GetAccessToken(ConsumerKey, ConsumerSecret, requestToken, verifier);
		}

		public static string GetResponseContent(string response, string tagName)
		{
			var serializer = new JavaScriptSerializer();
			var responseDictionary = (Dictionary<string,object>)serializer.DeserializeObject(response);

			return responseDictionary.ContainsKey(tagName) ? responseDictionary[tagName].ToString() : string.Empty;
		}
	}
}