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; }
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; }
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; }
private static void ReadToken(StreamReader streamReader, Token token) { token.Key = streamReader.ReadLine(); token.Secret = streamReader.ReadLine(); }
private IAuthenticatedUser GetAuthenticatedUser(Token token) { var credentials = Auth.SetUserCredentials(ConsumerKey, ConsumerSecret, token.Key, token.Secret); var user = User.GetAuthenticatedUser(credentials); return user; }
public IEnumerable<ITweet> GetTimeline(Token token) { var user = GetAuthenticatedUser(token); var statuses = user.GetHomeTimeline(); return statuses; }
public Token CreateTokenFromPin(string pin) { var userCredentials = AuthFlow.CreateCredentialsFromVerifierCode(pin, authenticationContext); var token = new Token { Key = userCredentials.AccessToken, Secret = userCredentials.AccessTokenSecret }; return token; }