示例#1
0
文件: Token.cs 项目: slieser/sandbox2
 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
文件: Token.cs 项目: slieser/sandbox2
 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
文件: Token.cs 项目: slieser/sandbox2
 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;
 }