0

I'm working on a project that uses the Twitter ruby gem, and I want to be able to "undo" a retweet. I've had no luck so far by trying to search for the original tweet and then removing the first occurrence, if it belongs to me. There's an unfavorite method, but no unretweet which is annoying. The only helpful thing so far is that I know if it has been retweeted or not. For this purpose, I can only see tweets that mention me.

Blease
  • 1,380
  • 4
  • 38
  • 64

2 Answers2

0

You can try this: Twitter.status_destroy(id)

dx7
  • 804
  • 5
  • 11
  • I don't know the ID of the status unless I'm looking at the timeline of retweets by me. For this purpose, I can only see tweets that mention me. – Blease Apr 21 '15 at 00:10
  • How could you undo the retweet if you don't know what tweet undo? – dx7 Apr 21 '15 at 00:15
  • Just as clicking the retweet button on a tweet on twitter undoes the retweet. I was hoping to use current_user_retweet but the gem doesn't support it. – Blease Apr 21 '15 at 00:36
  • When you click the retweet button on a tweet you click on a object so you know its id. If you need know the last tweet retweeted you can save it somewhere. – dx7 Apr 21 '15 at 00:41
0

As @dx7 says, you need to know ahead of time the ID of the original tweet, or the info related to the retweet and save it if you intend to undo the retweet.

If you have the ID of the original retweet, you can use Twitter.retweets(tweet_id, options = {}) to get a list of retweets and then you can find the one by the current_user and destroy it as @dx7 says.

Otherwise, you can try Twitter.retweeted_by_user(user, options = {}) to get a list of the last 20 retweets (default) by that user to find the retweet you want, get its ID, and destroy it.