Initial API exploration with default max outputs (100 messages by query), before implementing pagination.
This commit is contained in:
parent
9401982be6
commit
49b194ba8d
5
Datanalitica.package/.filetree
Normal file
5
Datanalitica.package/.filetree
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"separateMethodMetaAndSource" : false,
|
||||
"noMethodMetaData" : true,
|
||||
"useCypressPropertiesFile" : true
|
||||
}
|
0
Datanalitica.package/TwitterAPI.class/README.md
Normal file
0
Datanalitica.package/TwitterAPI.class/README.md
Normal file
3
Datanalitica.package/TwitterAPI.class/class/keys.st
Normal file
3
Datanalitica.package/TwitterAPI.class/class/keys.st
Normal file
@ -0,0 +1,3 @@
|
||||
accessing
|
||||
keys
|
||||
^ keys ifNil: [ keys := Dictionary new]
|
4
Datanalitica.package/TwitterAPI.class/class/loadKeys.st
Normal file
4
Datanalitica.package/TwitterAPI.class/class/loadKeys.st
Normal file
@ -0,0 +1,4 @@
|
||||
accessing
|
||||
loadKeys
|
||||
keys := STONJSON fromString: FileLocator home / '.config/Datanalitica/twitter-api-keys.json' contents.
|
||||
^ self keys
|
@ -0,0 +1,3 @@
|
||||
accessing
|
||||
bearerKey
|
||||
self keys at: 'Bearer Token'
|
@ -0,0 +1,3 @@
|
||||
accessing
|
||||
bearerToken
|
||||
^ self keys at: 'Bearer Token'
|
@ -0,0 +1,3 @@
|
||||
accessing
|
||||
defaultQueryParameters
|
||||
^ '?tweet.fields=created_at&expansions=author_id&user.fields=created_at&max_results=100'
|
3
Datanalitica.package/TwitterAPI.class/instance/keys.st
Normal file
3
Datanalitica.package/TwitterAPI.class/instance/keys.st
Normal file
@ -0,0 +1,3 @@
|
||||
accessing
|
||||
keys
|
||||
^ keys ifNil: [ keys := Dictionary new]
|
@ -0,0 +1,4 @@
|
||||
accessing
|
||||
loadKeys
|
||||
keys := self class loadKeys.
|
||||
^ keys
|
@ -0,0 +1,6 @@
|
||||
accessing
|
||||
rawResponseForURL: anUrl
|
||||
^ ZnClient new
|
||||
headerAt: 'Authorization' put: 'Bearer ', self bearerToken;
|
||||
url: anUrl;
|
||||
get.
|
@ -0,0 +1,5 @@
|
||||
queries
|
||||
userIDFrom: username
|
||||
| rawResponse |
|
||||
rawResponse := self rawResponseForURL: self usersBaseEndPoint, 'by/username/', username.
|
||||
^ (STONJSON fromString: rawResponse) at: 'data' at: 'id'
|
@ -0,0 +1,7 @@
|
||||
accessing
|
||||
userMentionsFor: username
|
||||
| rawResponse queryURL parameters |
|
||||
"The following query gets the last tweets, that is the maximun allowed for a particular user without pagination:"
|
||||
queryURL := self usersBaseEndPoint, (self userIDFrom: username), '/mentions', self defaultQueryParameters.
|
||||
rawResponse := self rawResponseForURL:queryURL.
|
||||
^ (STONJSON fromString: rawResponse)
|
@ -0,0 +1,8 @@
|
||||
accessing
|
||||
userTweetsFor: username
|
||||
| rawResponse queryURL parameters |
|
||||
"The following query gets the last 100 tweets, that is the maximun allowed for a particular user without pagination:"
|
||||
parameters := '?tweet.fields=created_at&expansions=author_id&user.fields=created_at&max_results=100'.
|
||||
queryURL := self usersBaseEndPoint, (self userIDFrom: username), '/tweets', parameters.
|
||||
rawResponse := self rawResponseForURL:queryURL.
|
||||
^ (STONJSON fromString: rawResponse)
|
@ -0,0 +1,8 @@
|
||||
accessing
|
||||
userTweetsFrom: username
|
||||
| rawResponse queryURL parameters |
|
||||
"The following query gets the last 100 tweets, that is the maximun allowed for a particular user without pagination:"
|
||||
parameters := '?tweet.fields=created_at&expansions=author_id&user.fields=created_at&max_results=100'.
|
||||
queryURL := self usersBaseEndPoint, (self userIDFrom: username), '/tweets', parameters.
|
||||
rawResponse := self rawResponseForURL:queryURL.
|
||||
^ (STONJSON fromString: rawResponse)
|
@ -0,0 +1,3 @@
|
||||
utilities api
|
||||
usersBaseEndPoint
|
||||
^ 'https://api.twitter.com/2/users/'
|
13
Datanalitica.package/TwitterAPI.class/properties.json
Normal file
13
Datanalitica.package/TwitterAPI.class/properties.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"commentStamp" : "",
|
||||
"super" : "Object",
|
||||
"category" : "Datanalitica",
|
||||
"classinstvars" : [ ],
|
||||
"pools" : [ ],
|
||||
"classvars" : [
|
||||
"keys"
|
||||
],
|
||||
"instvars" : [ ],
|
||||
"name" : "TwitterAPI",
|
||||
"type" : "normal"
|
||||
}
|
1
Datanalitica.package/monticello.meta/categories.st
Normal file
1
Datanalitica.package/monticello.meta/categories.st
Normal file
@ -0,0 +1 @@
|
||||
SystemOrganization addCategory: #Datanalitica!
|
1
Datanalitica.package/monticello.meta/package
Normal file
1
Datanalitica.package/monticello.meta/package
Normal file
@ -0,0 +1 @@
|
||||
(name 'Datanalitica')
|
1
Datanalitica.package/properties.json
Normal file
1
Datanalitica.package/properties.json
Normal file
@ -0,0 +1 @@
|
||||
{ }
|
Loading…
Reference in New Issue
Block a user