[英]Twitter API Get Tweet ID
I'm using an auto poster to post news stories to the Twitter account using the Twitter API 1.1. 我正在使用自动海报通过Twitter API 1.1将新闻故事发布到Twitter帐户。
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? 为此,我认为如果我可以获取该tweet的ID并将其存储在数据库中,则可以通过这种方式将其删除,但是我似乎无法获取实际tweet的ID,因为这样做会导致感? 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.
我能找到的最好方法是使用API搜索Twitter帐户并获取最新的tweet,但是存在最新tweet并非实际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. 我仔细阅读了API文档,发现没有什么可以使您返回推特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.
我也在这里查看,这是我得到的最接近的内容: 如何获取tweet的ID但是,它再次搜索而不是返回特定的ID。
You can POST your tweets to the post/statuses/update endpoint. 您可以将您的推文发布到发布/状态/更新端点。
You can then read ID as id_str
in the response dictionary. 然后,您可以在响应字典
id_str
ID读取为id_str
。
If you are using node.js, you could use 如果您使用的是node.js,则可以使用
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;
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.