skip to Main Content

I am using R and I need to retrieve the few most recent posts from a Twitter user (@ExpressNewsPK) using twitteR api. I have created an account and have an access token, etc. I have used the following command to extract the tweets:

setup_twitter_oauth(consumerkey,consumersecret,accesstoken,accesssecret)
express_news_tweets <- searchTwitter("@ExpressNewsPK", n = 10, lang = "en" )

However, the posts that are returned aren’t the most recent ones from this user. Where have I made a mistake?

2

Answers


  1. When you use searchTwitter(), you call the Twitter Search API. Search API only returns a sample history of the tweets.

    What you really need to do is to call Twitter Streaming API. Using it you’ll be able to download tweets in near real time. You can read more about the Streaming API here: https://dev.twitter.com/streaming/overview

    Login or Signup to reply.
  2. I think searchTwitter would search with the search string provided (here @ExpressNewsPK). So instead of giving tweets by @ExpressNewsPK it would give tweets which are directed to @ExpressNewsPK.

    To get tweets from @ExpressNewsPK, you have a function named userTimeline which would give tweets from a particular user.

    So after you are done with setup_twitter_oauth, you can try

    userTimeline("ExpressNewsPK")
    

    read more about it at ?userTimeline

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search