Пример #1
0
 public static Token ReadFromRessource(Assembly assembly, string name) {
     var token = new Token();
     var stream = assembly.GetManifestResourceStream(name);
     using (var streamReader = new StreamReader(stream)) {
         ReadToken(streamReader, token);
     }
     return token;
 }
Пример #2
0
 public static Token ReadFromFile(string name) {
     var token = new Token();
     using (var stream = new FileStream(name, FileMode.Open)) {
         using (var streamReader = new StreamReader(stream)) {
             ReadToken(streamReader, token);
         }
     }
     return token;
 }
Пример #3
0
 public string Tweet(string message, Token token) {
     var user = GetAuthenticatedUser(token);
     var response = user.PublishTweet(message);
     if (response == null) {
         var twitterException = ExceptionHandler.GetLastException();
         var status = GetExceptionInfos(twitterException);
         return status;
     }
     return response.IdStr;
 }
Пример #4
0
 private static void ReadToken(StreamReader streamReader, Token token) {
     token.Key = streamReader.ReadLine();
     token.Secret = streamReader.ReadLine();
 }
Пример #5
0
 private IAuthenticatedUser GetAuthenticatedUser(Token token) {
     var credentials = Auth.SetUserCredentials(ConsumerKey, ConsumerSecret, token.Key, token.Secret);
     var user = User.GetAuthenticatedUser(credentials);
     return user;
 }
Пример #6
0
 public IEnumerable<ITweet> GetTimeline(Token token) {
     var user = GetAuthenticatedUser(token);
     var statuses = user.GetHomeTimeline();
     return statuses;
 }
Пример #7
0
 public Token CreateTokenFromPin(string pin) {
     var userCredentials = AuthFlow.CreateCredentialsFromVerifierCode(pin, authenticationContext);
     var token = new Token { Key = userCredentials.AccessToken, Secret = userCredentials.AccessTokenSecret };
     return token;
 }