I would like to programmatically identify when someone replies to one of my tweets. As far as I can tell, the Twitter API does not as of yet provide this functionality, so we must resort to workarounds. I cannot find information about this topic (that I can comprehend) and am trying to implement this solution from a StackOverflow discussion.

Start the service and pat myself on the back for achieving the social-media achievment of 100 friends (most of them not bots). Then grab my recent tweets, knowing already that the 6th tweet returned is the one I'm interested in.

t = ServiceConnect["Twitter", "New"]
t["UserData", "Username" -> "Bobthechemist"]
tweet = t["TweetList", "Username" -> "bobthechemist", MaxItems -> 25][6]

I then look for all tweets to me, and filter (using Select) those posted after the tweet of interest. I suspect there is a way to do this with the connected service, but I cannot figure out how to to a tweet search using "SinceID" as a parameter.

res = t["TweetSearch", "Query" -> "to:@bobthechemist"]
res2 = Select[res, #ID > tweet["ID"] &]

Here's where I run into problems. I know that the third entry in res2 contains a tweet that is in response to one of mine; however, I see nothing in the tweet details that suggests as such:

t["GetTweet", "TweetID" -> res[3]["ID"], "Elements" -> "FullData"]

It looks like there is a parameter called in_reply_to_status_id in the JSON data; however I have no idea how to check if that is really true (the information I'm working with is OLD and the API has undoubtedly changed) and if it is true, if the Mathematica Service is capable of grabbing that information.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.