Esempio n. 1
0
 private static void FavTweetCore(AccountInfo d, TweetViewModel status)
 {
     /*
     if (ApiHelper.ExecApi(() => d.CreateFavorites(status.Status.Id)) == null)
         throw new ApplicationException();
     */
     for (int i = 0; i < 3; i++)
     {
         try
         {
             if (d.CreateFavorites(status.Status.Id) != null)
                 break;
         }
         catch (WebException wex)
         {
             var hwr = wex.Response as HttpWebResponse;
             if (wex.Status == WebExceptionStatus.ProtocolError &&
                 hwr != null && hwr.StatusCode == HttpStatusCode.Forbidden)
             {
                 // あとIt's great that ... ならふぁぼ規制
                 using (var read = new StreamReader( hwr.GetResponseStream()))
                 {
                     var desc = read.ReadToEnd();
                     if (desc.Contains("It's great that you like so many updates, but we only allow so many updates to be marked as a favorite per day."))
                     {
                         throw new FavoriteSuspendedException();
                     }
                 }
             }
             else if (wex.Status == WebExceptionStatus.Timeout)
             {
                 continue;
             }
             else
             {
                 break;
             }
         }
     }
 }
Esempio n. 2
0
 private static void FavTweetCore(AccountInfo d, TweetViewModel status)
 {
     if (ApiHelper.ExecApi(() => d.CreateFavorites(status.Status.Id)) == null)
         throw new ApplicationException();
 }