2021-06-30 20:56:53 +00:00
|
|
|
accessing
|
|
|
|
userTweetsFrom: username since: startDateString until: endDateString
|
|
|
|
| nextToken queryUrl sinceDate untilDate messages response |
|
|
|
|
|
2021-07-16 12:00:58 +00:00
|
|
|
sinceDate := 'start_time=',startDateString, 'T00:00:00Z'.
|
|
|
|
untilDate := 'end_time=',endDateString, 'T23:59:59Z'.
|
2021-06-30 20:56:53 +00:00
|
|
|
messages := OrderedCollection new.
|
|
|
|
nextToken := ''.
|
|
|
|
[ nextToken includesSubstring: 'stop' ] whileFalse: [
|
|
|
|
queryUrl := self usersBaseEndPoint,
|
2021-07-16 12:00:58 +00:00
|
|
|
(self userIDFrom: username), '/tweets', (self defaultQueryParameters at: 'tweets'),
|
2021-06-30 20:56:53 +00:00
|
|
|
'&', sinceDate,
|
|
|
|
'&', untilDate,
|
|
|
|
'&', nextToken.
|
|
|
|
response := STONJSON fromString: (self rawResponseForURL: queryUrl).
|
2021-06-30 23:58:53 +00:00
|
|
|
(response at: 'data') do: [:tweetData |
|
|
|
|
messages add: (Tweet new fromDictionary: tweetData)
|
|
|
|
].
|
2021-06-30 20:56:53 +00:00
|
|
|
nextToken := 'pagination_token=',((response at: 'meta') at: 'next_token' ifAbsent: [ 'stop' ])].
|
|
|
|
^ messages.
|