当前位置: 首页>>代码示例>>C#>>正文


C# TwitterContext.DeleteTweetAsync方法代码示例

本文整理汇总了C#中LinqToTwitter.TwitterContext.DeleteTweetAsync方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterContext.DeleteTweetAsync方法的具体用法?C# TwitterContext.DeleteTweetAsync怎么用?C# TwitterContext.DeleteTweetAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LinqToTwitter.TwitterContext的用法示例。


在下文中一共展示了TwitterContext.DeleteTweetAsync方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ClearOldTwits

 private static async Task ClearOldTwits(TwitterContext twitterCtx)
 {
     var statuses = (from status in twitterCtx.Status
                        where status.Type == StatusType.User &&
                             status.Entities.HashTagEntities.Any(h=>h.Tag == "sdpf")
                        select status.StatusID).ToArray();
     var tasks = from id in statuses
               select twitterCtx.DeleteTweetAsync(id);
     await Task.WhenAll(tasks);
 }
开发者ID:bnayae,项目名称:SDP-2015,代码行数:10,代码来源:TwitterServices.cs

示例2: Send

        public static void Send(string msg)
        {
            TwitterContext context = new TwitterContext(new MvcAuthorizer()
            {
                CredentialStore = new LinqToTwitter.InMemoryCredentialStore()
                {
                    OAuthTokenSecret = ConfigurationManager.AppSettings["OAuthTokenSecret"],
                    ConsumerKey = ConfigurationManager.AppSettings["ConsumerKey"],
                    ConsumerSecret = ConfigurationManager.AppSettings["ConsumerSecret"],
                    OAuthToken = ConfigurationManager.AppSettings["OAuthToken"]
                }
            });

            var tweetTask = context.TweetAsync(msg);
            tweetTask.Wait();
            if (!tweetTask.IsFaulted)
            {
                var status = tweetTask.Result;
                if (status != null)
                {
                    context.DeleteTweetAsync(status.StatusID).Wait();
                }
            }
        }
开发者ID:postworthy,项目名称:TwitterCommandAndControl,代码行数:24,代码来源:Messenger.cs

示例3: DeleteTweetAsync

        static async Task DeleteTweetAsync(TwitterContext twitterCtx)
        {
            ulong tweetID = 280433519057068033;

            Status status = 
                await twitterCtx.DeleteTweetAsync(tweetID);

            if (status != null && status.User != null)
                Console.WriteLine(
                    "(" + status.StatusID + ")" +
                    "[" + status.User.UserID + "]" +
                    status.User.ScreenNameResponse + ", " +
                    status.Text + ", " +
                    status.CreatedAt);
        }
开发者ID:yaremado,项目名称:LinqToTwitter,代码行数:15,代码来源:StatusDemos.cs

示例4: EraseTweetsAction

        //We start multiple actions in parallel to delete tweets
        void EraseTweetsAction(TwitterContext ctx, CancellationToken cancellationToken)
        {
            int nextTweetID = getNextTweetIDSync();

            #if DEBUG_TEST
            Random rnd = new Random();
            #endif

            //Are we done?
            while (nextTweetID != Int32.MinValue)
            {
                //We can't cancel here, we have already fetched a new ID and if we cancel here it will never be deteled
                Tweet tweet = mTweetsCollection[nextTweetID];

                //Clear Tweets logic here
                try
                {
            #if DEBUG_TEST
                    Thread.Sleep(sleepFakeWaitMilliseconds);
                    if (rnd.Next() % 3 == 0)    // Simulate error
                    {
                        throw new ArgumentNullException();
                    }
                    else
                    {
                        Exception e = new Exception("Sorry, that page does not exist");
                        throw new Exception("", e);
                    }
            #else
                    ulong tid = ulong.Parse(tweet.ID);
                    Status ret = null;
                    DirectMessage ret2 = null;

                    switch (TweetsEraseType)
                    {
                        case ApplicationSettings.EraseTypes.TweetsAndRetweets:
                            ret = ctx.DeleteTweetAsync(tid).Result;
                            break;
                        case ApplicationSettings.EraseTypes.Favorites:
                            ret = ctx.DestroyFavoriteAsync(tid).Result;
                            break;
                        case ApplicationSettings.EraseTypes.DirectMessages:
                            ret2 = ctx.DestroyDirectMessageAsync(tid, true).Result;
                            break;
                        default:
                            break;
                    }
            #endif
                    tweet.Status = STATUS_DELETED;
                }
                catch (Exception ex)
                {
                    TwitterQueryException exception = ex.InnerException as TwitterQueryException;
                    if (exception != null && exception.StatusCode == System.Net.HttpStatusCode.NotFound)
                    {
                        tweet.Status = STATUS_NOT_FOUND;
                    }
                    else if (exception != null &&
                            (exception.StatusCode == System.Net.HttpStatusCode.Unauthorized || exception.StatusCode == System.Net.HttpStatusCode.Forbidden))
                    {
                        tweet.Status = STATUS_NOT_ALLOWED;
                    }
                    else
                    {
                        tweet.Status = STATUS_ERROR;
                        var tmp = new JsonTweet() { created_at = Helpers.DateTimeToString(tweet.Date), id_str = tweet.ID, text = tweet.Text };

                        lock (_lockerNotDeletedTweetsLst)
                        {
                            notDeletedTweets.Add(tmp);
                        }
                    }
                }
                finally
                {
                    onDeletedTweetUIUpdate(tweet);
                }

                //We cancel once a tweet is completely handeled, we make sure not to request for a new one
                if (cancellationToken.IsCancellationRequested)
                {
                    return;
                }

                nextTweetID = getNextTweetIDSync();
            }
        }
开发者ID:drsaraalsa3ed,项目名称:Twitter-Archive-Eraser,代码行数:88,代码来源:DeleteTweets.xaml.cs

示例5: DeleteTweet

        public static async Task<bool> DeleteTweet(long refid)
        {
            try
            {
                var twitterCtx = new TwitterContext(auth);
                Status status = await twitterCtx.DeleteTweetAsync((ulong)refid);
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }

        }
开发者ID:Ruekov,项目名称:gestTweet,代码行数:14,代码来源:TweetAPI.cs


注:本文中的LinqToTwitter.TwitterContext.DeleteTweetAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。