Mercurial > altnet-hispano
annotate Agendas/trunk/src/Agendas.Twitter/oAuthTwitter.cs @ 107:1ee5711256db
Utilizando Twitterizer en adapter a Twitter
author | Nelo@Kenia.neluz.int |
---|---|
date | Tue, 07 Jun 2011 21:03:56 -0300 |
parents | db4b1e2cae49 |
children | a456eb519e23 |
rev | line source |
---|---|
107
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
1 using System; |
90
d1688622fa88
Autenticando con twitter (falta emprolijar el código, pero autentica!)
Nelo@Kenia.neluz.int
parents:
diff
changeset
|
2 using System.Configuration; |
107
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
3 using Twitterizer; |
90
d1688622fa88
Autenticando con twitter (falta emprolijar el código, pero autentica!)
Nelo@Kenia.neluz.int
parents:
diff
changeset
|
4 |
d1688622fa88
Autenticando con twitter (falta emprolijar el código, pero autentica!)
Nelo@Kenia.neluz.int
parents:
diff
changeset
|
5 namespace AltNetHispano.Agendas.Twitter |
d1688622fa88
Autenticando con twitter (falta emprolijar el código, pero autentica!)
Nelo@Kenia.neluz.int
parents:
diff
changeset
|
6 { |
107
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
7 public class OAuthTwitter |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
8 { |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
9 private string ConsumerKey |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
10 { |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
11 get { return ConfigurationManager.AppSettings["consumerKey"]; } |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
12 } |
90
d1688622fa88
Autenticando con twitter (falta emprolijar el código, pero autentica!)
Nelo@Kenia.neluz.int
parents:
diff
changeset
|
13 |
107
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
14 private string ConsumerSecret |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
15 { |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
16 get { return ConfigurationManager.AppSettings["consumerSecret"]; } |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
17 } |
90
d1688622fa88
Autenticando con twitter (falta emprolijar el código, pero autentica!)
Nelo@Kenia.neluz.int
parents:
diff
changeset
|
18 |
107
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
19 public Uri AuthorizationLinkGet(string callbackAddress) |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
20 { |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
21 // Obtain a request token |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
22 OAuthTokenResponse requestToken = OAuthUtility.GetRequestToken(ConsumerKey, ConsumerSecret, callbackAddress); |
90
d1688622fa88
Autenticando con twitter (falta emprolijar el código, pero autentica!)
Nelo@Kenia.neluz.int
parents:
diff
changeset
|
23 |
107
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
24 // Direct or instruct the user to the following address: |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
25 Uri authorizationUri = OAuthUtility.BuildAuthorizationUri(requestToken.Token); |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
26 |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
27 return authorizationUri; |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
28 } |
90
d1688622fa88
Autenticando con twitter (falta emprolijar el código, pero autentica!)
Nelo@Kenia.neluz.int
parents:
diff
changeset
|
29 |
107
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
30 public string AccessTokenGet(string requestToken, string verifier) |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
31 { |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
32 OAuthTokenResponse accessToken = OAuthUtility.GetAccessToken(ConsumerKey, ConsumerSecret, requestToken, verifier); |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
33 if (accessToken!=null) |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
34 { |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
35 var tokens = new OAuthTokens |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
36 { |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
37 AccessToken = accessToken.Token, |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
38 AccessTokenSecret = accessToken.TokenSecret, |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
39 ConsumerKey = ConsumerKey, |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
40 ConsumerSecret = ConsumerSecret |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
41 }; |
90
d1688622fa88
Autenticando con twitter (falta emprolijar el código, pero autentica!)
Nelo@Kenia.neluz.int
parents:
diff
changeset
|
42 |
107
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
43 TwitterResponse<TwitterUser> showUserResponse = TwitterUser.Show(tokens, accessToken.UserId); |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
44 if (showUserResponse.Result == RequestResult.Success) |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
45 return showUserResponse.Content; |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
46 return showUserResponse.ErrorMessage; |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
47 } |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
48 return string.Empty; |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
49 } |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
50 } |
90
d1688622fa88
Autenticando con twitter (falta emprolijar el código, pero autentica!)
Nelo@Kenia.neluz.int
parents:
diff
changeset
|
51 } |