timeline.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package anaconda
  2. import (
  3. "net/url"
  4. )
  5. // GetHomeTimeline returns the most recent tweets and retweets posted by the user
  6. // and the users that they follow.
  7. // https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-home_timeline
  8. // By default, include_entities is set to "true"
  9. func (a TwitterApi) GetHomeTimeline(v url.Values) (timeline []Tweet, err error) {
  10. v = cleanValues(v)
  11. if val := v.Get("include_entities"); val == "" {
  12. v.Set("include_entities", "true")
  13. }
  14. response_ch := make(chan response)
  15. a.queryQueue <- query{a.baseUrl + "/statuses/home_timeline.json", v, &timeline, _GET, response_ch}
  16. return timeline, (<-response_ch).err
  17. }
  18. // GetUserTimeline returns a collection of the most recent Tweets posted by the user indicated by the screen_name or user_id parameters.
  19. // https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-user_timeline
  20. func (a TwitterApi) GetUserTimeline(v url.Values) (timeline []Tweet, err error) {
  21. response_ch := make(chan response)
  22. a.queryQueue <- query{a.baseUrl + "/statuses/user_timeline.json", v, &timeline, _GET, response_ch}
  23. return timeline, (<-response_ch).err
  24. }
  25. // GetMentionsTimeline returns the most recent mentions (Tweets containing a users’s @screen_name) for the authenticating user.
  26. // The timeline returned is the equivalent of the one seen when you view your mentions on twitter.com.
  27. // https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-mentions_timeline
  28. func (a TwitterApi) GetMentionsTimeline(v url.Values) (timeline []Tweet, err error) {
  29. response_ch := make(chan response)
  30. a.queryQueue <- query{a.baseUrl + "/statuses/mentions_timeline.json", v, &timeline, _GET, response_ch}
  31. return timeline, (<-response_ch).err
  32. }
  33. // GetRetweetsOfMe returns the most recent Tweets authored by the authenticating user that have been retweeted by others.
  34. // https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-retweets_of_me
  35. func (a TwitterApi) GetRetweetsOfMe(v url.Values) (tweets []Tweet, err error) {
  36. response_ch := make(chan response)
  37. a.queryQueue <- query{a.baseUrl + "/statuses/retweets_of_me.json", v, &tweets, _GET, response_ch}
  38. return tweets, (<-response_ch).err
  39. }