Exemple #1
0
 public static bool IsValid(TwitterAccount account)
 {
     return account != null && !string.IsNullOrEmpty(account.AccessToken)
         && !string.IsNullOrEmpty(account.AccessTokenSecret)
         && account.UserID != 0
         && !string.IsNullOrEmpty(account.ScreenName);
 }
Exemple #2
0
        /// <summary>
        /// アクセストークンを取得
        /// </summary>
        public void GetAccessToken(string verifier, Action<bool, string> completed)
        {
            OAuthRequest(ACCESS_TOKEN_URL + "?oauth_verifier=" + verifier,
                "GET", oauth_token, oauth_token_secret, (sender, e) =>
            {
                if (e.Error == null)
                {
                    //oauth_token=5458012-PNBuQ6aI4gbC1nprVuOF4XsyXuIt65GSHAyCZGnKl8&oauth_token_secret=lzpqHYwQD2thDdE33cijSenuAubkqY7TJbXdEvHs4&user_id=5458012&screen_name=gaeeyo
                    Dictionary<string, string> query = QueryParamsToDic(e.Result);

                    try {
                        var newAccount = new TwitterAccount()
                        {
                            AccessToken = query["oauth_token"],
                            AccessTokenSecret = query["oauth_token_secret"],
                            UserID = Convert.ToUInt64(query["user_id"]),
                            ScreenName = query["screen_name"],
                        };
                        Account = newAccount;
                        completed(true, "");
                    }
                    catch (Exception) {
                        completed(false, "サーバからの応答が想定外でした。");
                    }
                }
                else
                {
                    completed(false, e.Error.Message);
                }
            });
        }
Exemple #3
0
 public static TwitterAccount CreateFromApplicationSettings()
 {
     var s = System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings;
     var a = new TwitterAccount();
     try
     {
         a.AccessToken = (string)s[AccessTokenKey];
         a.AccessTokenSecret = (string)s[AccessTokenSecretKey];
         a.ScreenName = (string)s[ScreenNameKey];
         a.UserID = Convert.ToUInt64(s[UserIDKey]);
         return a;
     }
     catch(Exception) {
         return null;
     }
 }