Skip to content

Commit c979063

Browse files
authored
Switch Twitter client to use recent vs archival tweet search (#92)
1 parent c94c357 commit c979063

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pkg/twitter/client.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,15 @@ func (c *Client) GetUserTweets(ctx context.Context, userId string, maxResults in
109109
return tweets, err
110110
}
111111

112-
// SearchUserTweets searches for tweets made by a user
113-
func (c *Client) SearchUserTweets(ctx context.Context, userId, searchString string, maxResults int) ([]*Tweet, error) {
112+
// SearchRecentUserTweets searches for tweets made by a user within the last 7 days
113+
//
114+
// todo: Doesn't support paging, so only the most recent ones are returned
115+
func (c *Client) SearchRecentUserTweets(ctx context.Context, userId, searchString string, maxResults int) ([]*Tweet, error) {
114116
tracer := metrics.TraceMethodCall(ctx, metricsStructName, "SearchUserTweets")
115117
defer tracer.End()
116118

117119
url := fmt.Sprintf(
118-
baseUrl+"tweets/search/all?query=%s&max_results=%d",
120+
baseUrl+"tweets/search/recent?query=%s&max_results=%d",
119121
url.QueryEscape(fmt.Sprintf("from:%s %s", userId, searchString)),
120122
maxResults,
121123
)

0 commit comments

Comments
 (0)