Mercurial > altnet-hispano
annotate Agendas/trunk/src/Agendas.Twitter/oAuthTwitter.cs @ 110:a456eb519e23
Lanzando twitts desde el sitio con la cuenta de AltNetHispanoDESA
author | Nelo@Kenia.neluz.int |
---|---|
date | Wed, 08 Jun 2011 07:33:14 -0300 |
parents | 1ee5711256db |
children | 90ce239cfa6d |
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 { |
110
a456eb519e23
Lanzando twitts desde el sitio con la cuenta de AltNetHispanoDESA
Nelo@Kenia.neluz.int
parents:
107
diff
changeset
|
11 get { return ConfigurationManager.AppSettings["consumerKeyAppSignIn"]; } |
107
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 { |
110
a456eb519e23
Lanzando twitts desde el sitio con la cuenta de AltNetHispanoDESA
Nelo@Kenia.neluz.int
parents:
107
diff
changeset
|
16 get { return ConfigurationManager.AppSettings["consumerSecretAppSignIn"]; } |
107
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); |
110
a456eb519e23
Lanzando twitts desde el sitio con la cuenta de AltNetHispanoDESA
Nelo@Kenia.neluz.int
parents:
107
diff
changeset
|
33 |
107
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
34 if (accessToken!=null) |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
35 { |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
36 var tokens = new OAuthTokens |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
37 { |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
38 AccessToken = accessToken.Token, |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
39 AccessTokenSecret = accessToken.TokenSecret, |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
40 ConsumerKey = ConsumerKey, |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
41 ConsumerSecret = ConsumerSecret |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
42 }; |
90
d1688622fa88
Autenticando con twitter (falta emprolijar el código, pero autentica!)
Nelo@Kenia.neluz.int
parents:
diff
changeset
|
43 |
107
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
44 TwitterResponse<TwitterUser> showUserResponse = TwitterUser.Show(tokens, accessToken.UserId); |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
45 if (showUserResponse.Result == RequestResult.Success) |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
46 return showUserResponse.Content; |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
47 return showUserResponse.ErrorMessage; |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
48 } |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
49 return string.Empty; |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
50 } |
1ee5711256db
Utilizando Twitterizer en adapter a Twitter
Nelo@Kenia.neluz.int
parents:
94
diff
changeset
|
51 } |
90
d1688622fa88
Autenticando con twitter (falta emprolijar el código, pero autentica!)
Nelo@Kenia.neluz.int
parents:
diff
changeset
|
52 } |