I’ve tried that and received an error saying “Unrecognized request option url”. I’ll provide the code I used.
local http = game:GetService("HttpService")
local client_id = "<your_client_id>" -- Replace <your_client_id> with your Twitch API client ID
local client_secret = "<your_client_secret>" -- Replace <your_client_secret> with your Twitch API client ID
local ClientAccountName = "<your_channel_name>"
local function GetToken()
-- Make an HTTP request to the Twitch API to get an access token
local url1 = "https://id.twitch.tv/oauth2/token"
local data = "client_id="..client_id.."&client_secret="..client_secret.."&grant_type=client_credentials"
local headers = {
["Content-Type"] = "application/x-www-form-urlencoded",
["Content-Length"] = #data,
}
local response, status, headers = http:RequestAsync({
url = url1.."&"..data,
method = "POST",
headers = headers,
})
-- Parse the response to extract the access token
if status == 200 then
local data = http:JSONDecode(response)
local access_token = data.access_token
print(access_token)
return access_token
else
print("Error getting access token: "..status)
return false
end
end
-- Make an HTTP request to the Twitch API to get the user's follower count
local url = "https://api.twitch.tv/helix/users/follows?to_id="..ClientAccountName
local headers = {
["Client-ID"] = client_id,
["Authorization"] = "Bearer "..GetToken(),
}
local response, status, headers = http:RequestAsync({
url = url,
headers = headers,
})
-- Parse the response to extract the follower countc
if status == 200 then
local data = http:JSONDecode(response)
local follower_count = data.total_followers
print("Follower count for "..ClientAccountName..": "..follower_count)
else
print("Error getting follower count: "..status)
end