MCPcopy Create free account
hub / github.com/Preloading/TwitterAPIBridge / trends_woeid

Function trends_woeid

twitterv1/discover.go:130–175  ·  view source on GitHub ↗

https://web.archive.org/web/20120313235613/https://dev.twitter.com/docs/api/1/get/trends/%3Awoeid The bluesky feature to make this possible was released 17 hours ago, and is "beta", so this is likely to break

(c *fiber.Ctx)

Source from the content-addressed store, hash-verified

128// https://web.archive.org/web/20120313235613/https://dev.twitter.com/docs/api/1/get/trends/%3Awoeid
129// The bluesky feature to make this possible was released 17 hours ago, and is "beta", so this is likely to break
130func trends_woeid(c *fiber.Ctx) error {
131 // We don't have location specific trends soooooo
132 // woeid := c.Params("woeid")
133
134 //auth
135 _, pds, _, oauthToken, err := GetAuthFromReq(c)
136
137 if err != nil {
138 blankstring := ""
139 oauthToken = &blankstring
140 }
141
142 // Get trends
143 bsky_trends, err := blueskyapi.GetTrends(*pds, *oauthToken)
144 if err != nil {
145 fmt.Println("Error:", err)
146 return HandleBlueskyError(c, err.Error(), "app.bsky.unspecced.getTrendingTopics", trends_woeid)
147 }
148
149 trends := []bridge.Trend{}
150
151 for _, trend := range bsky_trends.Topics {
152 topic_query := url.QueryEscape(trend.Topic)
153 topic_query = strings.ReplaceAll(topic_query, "%20", "+")
154 trends = append(trends, bridge.Trend{
155 Name: trend.Topic,
156 URL: "https://twitter.com/search?q=" + topic_query,
157 Promoted: false,
158 Query: topic_query,
159 TweetVolume: 1337, // We can't get this data without search every, single, topic. So we just make it up.
160 })
161
162 }
163
164 return EncodeAndSend(c, bridge.Trends{
165 Created: time.Now(),
166 Trends: trends,
167 AsOf: time.Now(), // no clue the differ
168 Locations: []bridge.TrendLocation{
169 {
170 Name: "Worldwide",
171 Woeid: 1, // Where on earth ID. Since bluesky trends are global, this is always 1
172 },
173 },
174 })
175}
176
177func discovery(c *fiber.Ctx) error {
178 // auth

Callers

nothing calls this directly

Calls 3

GetAuthFromReqFunction · 0.85
HandleBlueskyErrorFunction · 0.85
EncodeAndSendFunction · 0.85

Tested by

no test coverage detected