Replies to a particular tweet, Twitter API

后端 未结 11 2059
北荒
北荒 2020-11-28 02:19

Is there a way in the Twitter API to get the replies to a particular tweet? Thanks

11条回答
  •  情话喂你
    2020-11-28 02:47

    Here I am sharing simple R code to fetch reply of specific tweet

    userName = "SrBachchan"
    
    ##fetch tweets from @userName timeline
    tweets = userTimeline(userName,n = 1)
    
    ## converting tweets list to DataFrame  
    tweets <- twListToDF(tweets)  
    
    ## building queryString to fetch retweets 
    queryString = paste0("to:",userName)
    
    ## retrieving tweet ID for which reply is to be fetched 
    Id = tweets[1,"id"]  
    
    ## fetching all the reply to userName
    rply = searchTwitter(queryString, sinceID = Id) 
    rply = twListToDF(rply)
    
    ## eliminate all the reply other then reply to required tweet Id  
    rply = rply[!rply$replyToSID > Id,]
    rply = rply[!rply$replyToSID < Id,]
    rply = rply[complete.cases(rply[,"replyToSID"]),]
    
    ## now rply DataFrame contains all the required replies.
    

提交回复
热议问题