Socialmetrica/Datanalitica.package/TwitterAPI.class/instance/userMentionsFor.since..st

18 lines
750 B
Smalltalk
Raw Normal View History

2021-07-16 12:00:58 +00:00
accessing
userMentionsFor: username since: startDateString
| nextToken queryUrl sinceDate untilDate messages response |
sinceDate := 'start_time=',startDateString, 'T00:00:00Z'.
messages := OrderedCollection new.
nextToken := ''.
[ nextToken includesSubstring: 'stop' ] whileFalse: [
queryUrl := self usersBaseEndPoint,
(self userIDFrom: username), '/mentions', (self defaultQueryParameters at: 'mentionsOrig') ,
'&', sinceDate,
'&', nextToken.
response := STONJSON fromString: (self rawResponseForURL: queryUrl).
(response at: 'data') do: [:tweetData |
messages add: (Tweet new fromDictionary: tweetData)
].
nextToken := 'pagination_token=',((response at: 'meta') at: 'next_token' ifAbsent: [ 'stop' ])].
^ messages.