Replace inconsistent use of username with screen_name
This commit is contained in:
parent
b45aa84b1d
commit
6436cc2e57
8
main.go
8
main.go
|
@ -49,9 +49,9 @@ func probeTwitter(ctx context.Context, target string, registry *prometheus.Regis
|
|||
}
|
||||
|
||||
func twitterHandler(w http.ResponseWriter, r *http.Request) {
|
||||
username := r.URL.Query().Get("username")
|
||||
if username == "" {
|
||||
http.Error(w, "username parameter is missing", http.StatusBadRequest)
|
||||
screenName := r.URL.Query().Get("screen_name")
|
||||
if screenName == "" {
|
||||
http.Error(w, "screen_name parameter is missing", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ func twitterHandler(w http.ResponseWriter, r *http.Request) {
|
|||
ctx, cancel := context.WithTimeout(r.Context(), time.Duration(5*time.Second))
|
||||
defer cancel()
|
||||
|
||||
if success := probeTwitter(ctx, username, reg); !success {
|
||||
if success := probeTwitter(ctx, screenName, reg); !success {
|
||||
log.Error("Probe failed!")
|
||||
}
|
||||
|
||||
|
|
|
@ -9,4 +9,4 @@ A very simple prometheus exporter for getting the follower count of twitter acco
|
|||
- `/probe?screen_name=foo` - the follower count for twitter user with screen name foo
|
||||
|
||||
# How it do
|
||||
Uses the `https://cdn.syndication.twimg.com/widgets/followbutton/info.json` *unauthenticated* JSON API. Twitter may well turn this off or rate limit aggressively.
|
||||
Uses the `https://cdn.syndication.twimg.com/widgets/followbutton/info.json` *unauthenticated* JSON API. Twitter may well turn this off or rate limit aggressively.
|
||||
|
|
Loading…
Reference in New Issue