I’m trying to set up webhook with go lang.
I can get 202 Accepted Response from Twitch, but can not get challenge response.
I guess hub.callback is wrong. I set hub.callback to localhost like following code.
values := url.Values{}
values.Add("first", "1")
values.Add("to_id", "USER_ID")
topicURL := "https://api.twitch.tv/helix/users/follows?" + values.Encode()
jsonStr := map[string]string{"hub.mode": "subscribe", "hub.topic": topicURL, "hub.lease_seconds": "864000", "hub.callback": "http://localhost:8080/callback"}
jsonValues, _ := json.Marshal(jsonStr)
url := "https://api.twitch.tv/helix/webhooks/hub?"
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonValues))
req.Header.Set("Client-ID", "CLIENT_ID")
req.Header.Set("Content-Type", "application/json")
client := new(http.Client)
resp, err := client.Do(req)
Can not use localhost for testing ?