0

I'm using an auto poster to post news stories to the Twitter account using the Twitter API 1.1.

I have a slight problem though... If there is something wrong with the news story and it is deleted, I need to be able to delete the tweet automatically.

To do this, I thought that if I can get the ID of the tweet and store it in the database, I could delete it this way, but I can't seem to get the ID of the actual tweet as it tweets if that makes sense? The best way I could find was to use the API to search the Twitter account and get the latest tweet, but there's a risk that the latest tweet is not the actual tweet.

I had a look through the API documentation and there's nothing that I can see that enables you to return the tweet ID. I also looked on here, this was the closest I got: How to get id of the tweet But again, it searches rather than returns the specific ID.

Community
  • 1
  • 1
ScottC
  • 162
  • 1
  • 14
  • https://stackoverflow.com/questions/28384588/twitter-api-get-tweets-with-specific-id This post solves what you are looking for! – Manuel Minguez Dec 04 '18 at 21:05

2 Answers2

0

You can POST your tweets to the post/statuses/update endpoint.

You can then read ID as id_str in the response dictionary.

nst
  • 3,862
  • 1
  • 31
  • 40
0

If you are using node.js, you could use

    var params = {status:"This is a dummy tweet to get the current tweet ID. Time:" + currTime};
    client.post('statuses/update', params, function(error, tweets, response){
  if (!error) {
    console.log(tweets.id);
    tweetid = tweets.id;

  }
});