Jibril
Jibril

Reputation: 1037

Twitter GET not working with since_id

Working in R, but that shouldn't really matter.

I want to gather all tweets after : https://twitter.com/ChrisChristie/status/663046613779156996

So Tweet ID : 663046613779156996

    base = "https://ontributor_details = "contributor_details=true"
    ## include_rts
    include_rts = "include_rts=true"
    ## exclude_replies
    exclude_replies =         "exclude_replies=false"api.twitter.com/1.1/statuses/user_timeline.json?"
   queryName = "chrischristie"
   query = paste("q=", queryName, sep="")
   secondary_url = paste(query, count,        contributor_details,include_rts,exclude_replies, sep="&") 
   final_url = paste(base, secondary_url, sep="")
   timeline = GET(final_url, sig)

This (the above) works. There is no since_id. The URL comes out to be

   "https://api.twitter.com/1.1/statuses/user_timeline.json?q=chrischristie&count=200&contributor_details=true&include_rts=true&exclude_replies=false"

The below does not, just by adding in the following

cur_since_id_url = "since_id=663046613779156996"

secondary_url = paste(query, count, 

contributor_details,include_rts,exclude_replies,cur_since_id_url, sep="&")

final_url = paste(base, secondary_url, sep="")

timeline = GET(final_url, sig)

The url for the above there is

"https://api.twitter.com/1.1/statuses/user_timeline.json?q=chrischristie&count=200&contributor_details=true&include_rts=true&exclude_replies=false&since_id=663046613779156992"

Upvotes: 0

Views: 1023

Answers (1)

lukeA
lukeA

Reputation: 54237

This seems to work:

require(httr)
myapp <- oauth_app(
  "twitter",
   key = "......",
   secret = ".......")
twitter_token <- oauth1.0_token(oauth_endpoints("twitter"), myapp)
req <- GET("https://api.twitter.com/1.1/statuses/user_timeline.json",
           query = list(
             screen_name="chrischristie",
             count=10,
             contributor_details=TRUE,
             include_rts=TRUE,
             exclude_replies=FALSE,
             since_id=663046613779156992),
           config(token = twitter_token))
content(req)

Have a look at GET statuses/user_timeline

Upvotes: 1

Related Questions