How to get a user's sponsorship URL, if they have one? #133959
Replies: 2 comments
-
It seems to me the only way to do this at the moment is to check of a redirect away from func hasSponsorPage(username string, httpClient *http.Client) bool {
u := fmt.Sprintf("https://github.com/sponsors/%s", username)
httpClient.CheckRedirect = func(req *http.Request, via []*http.Request) error {
if strings.HasSuffix(req.Response.Header.Get("Location"), "com/"+username) {
return errors.New("skip redirect")
}
return nil
}
defer func() {
httpClient.CheckRedirect = nil
}()
req, err := http.NewRequest(http.MethodGet, u, nil)
if err != nil {
return false
}
_, err = httpClient.Do(req)
if err != nil {
return false
}
return true
} |
Beta Was this translation helpful? Give feedback.
-
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
-
Select Topic Area
Question
Body
curl https://api.github.com/users/<username>
is not returning a sponsorship URL for users I know have such a URL (e.g. my on username). How can I determine if a user has a sponsorship URL, and what that URL is if it exists?Beta Was this translation helpful? Give feedback.
All reactions