This project has moved and is read-only. For the latest updates, please go here.

Undo Retweet (WPF Application)

Sep 9, 2011 at 12:18 AM
Edited Sep 9, 2011 at 12:18 AM

Hi Joe and Everyone,

 I'm developing a WPF Application and I can't find a method to Undo a Retweet, I found the "DestroyFavorite" but I still can't found one to undo a retweet.
If someone knows hot can I do it please help me.

Sep 9, 2011 at 5:54 PM

Hi Sarah,

There isn't a specific API for undoing retweets.  However, you can use DestroyStatus(statusID).  The statusID argument will be the StatusID from the retweeted tweet.  If the user who tweeted uses this, it deletes the tweet.  However, if a user who retweeted does it, it undoes the retweet. If you use it on a tweet that doesn't belong to the user and the user hasn't retweeted, you'll receive an exception and the underlying message from Twitter will be that you can't delete a status that you haven't created.

Also, there are various ways to get a status and all of them don't return retweets.  If that happens, you can try to set the IncludeRetweets == true parameter.


Sep 13, 2011 at 11:58 PM

Thanks Joe,

I've tried with DestroyStatus(statusID) but it doesn't work...  I already checked and the statusID is ok, and the error says "Error while queryng twitter".
there's another way to do it? 

Sep 14, 2011 at 12:12 AM

This is a little tricky because I wasn't able to do it at first, but eventually got it to work.  I thought it was the StatusID that I used and now I'm wondering if I really used the Retweet ID instead.  Sorry if I gave you the wrong information.  I'm not able to look at it right now, but the way to do it is to get the status with the retweet info filled in and either use the StatusID or the ID from the Retweet object.


Sep 15, 2011 at 1:57 AM

Mmm Yeah it is tricky, I'm gonna try to do it because it's the only thing that the application doesn't do. 

Thanks anyway :)

Nov 2, 2011 at 3:03 AM

Hi Joe!  I can't undo the retweet yet, can you look the method that you used to do it??

Thanks in advance.

Nov 2, 2011 at 3:25 AM

Hey Sarah,

I'll look into it and put together some samples.


Nov 2, 2011 at 6:13 AM
Edited Nov 2, 2011 at 6:19 AM

Hi Sarah,

I've created a sample program here that does a retweet and then undoes the retweet:

Look in the Console Samples section.  Like I said, this is a little tricky, so I'll do a quick walkthrough.

The first part of the example gets the Status that will be retweeted.  I just grab the last tweet from my home timeline like this:

                var joeMayoTweet =
                    (from tweet in ctx.Status
                     where tweet.Type == StatusType.Home &&
                           tweet.ScreenName == "JoeMayo"
                     select tweet)

After getting the tweet, I print out it's Status ID.  Pay attention to the status ID because it will change after the initial retweet.  Also, if you look at the returned status object, you'll notice that the Retweet property is null.  Here's the print out:

------------ Begin Tweet Info ------------
joeMayoTweet.StatusID: 129939459180470273
joeMayoTweetRetweet Property is  null.
------------ End Tweet Info ------------

The next part of the code actually does the retweet, which you're probably already familiar with:

                Status retweetedTweet;

                if (retweetKey.Key != ConsoleKey.Q)
                    retweetedTweet = ctx.Retweet(joeMayoTweet.StatusID);
                    PrintTweetInfo(retweetedTweet, "retweetedTweet");

When the retweet is complete, it returns the retweeted status.  This returned status differs from the original status because the status ID has changed.  However, the Retweet property is now instantiated with a Retweet object.  In the print out below, notice that the ID of the Retweet has the status ID from the original tweet:

------------ Begin Tweet Info ------------
retweetedTweet.StatusID: 131592651395960832
retweetedTweetRetweet Property is not null.
retweetedTweet.Retweet.ID: 129939459180470273
------------ End Tweet Info ------------

Essentially, this is where the confusion came in because it's easy to use the StatusID of the original tweet, rather than the StatusID of the retweeted Status when doing the undo.  Here's the code that does the undo:

                    Status undoneRetweetStatus = ctx.DestroyStatus(retweetedTweet.StatusID);

In the example above, notice that the method call to undo the retweet is DestroyStatus; Strange, I know.  What's more important is the fact that we're passing the StatusID of the retweeted tweet.  The Status returned by DestroyStatus is the same as the retweeted tweet, shown below:

------------ Begin Tweet Info ------------
undoneRetweetStatus.StatusID: 131592651395960832
undoneRetweetStatusRetweet Property is not null.
undoneRetweetStatus.Retweet.ID: 129939459180470273
------------ End Tweet Info ------------

Hopefully, this will get you going in the right direction.  Let me know if you have questions.  You're also welcome to come back and add any of your own observations in addition to what I've included here to add to the knowledge base.