Its a nightmare ( DONT DO IT )
- get an auth access thingy
local HttpService = game:GetService("HttpService")
local AuthLink = "https://api.twitter.com/oauth2/token"
local Encode = nil -- monstrosity at the bottom
local function GetAuth(ConsumerKey, SecretKey)
local Data = HttpService:PostAsync(
AuthLink,
"grant_type=client_credentials",
Enum.HttpContentType.ApplicationUrlEncoded,
false,
{Authorization = "Basic " .. Encode(ConsumerKey.. ":" .. SecretKey)}
)
return string.gsub(
HttpService:JSONDecode(Data).access_token,
"%%%x%x",
function(Replacement)
return string.char(tonumber(string.sub(Replacement, 2), 16))
end
)
end
Encode = function(data)
-- gotta add in the credits
-- Lua 5.1+ base64 v3.0 (c) 2009 by Alex Kloss <alexthkloss@web.de>
-- licensed under the terms of the LGPL2
local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
return ((data:gsub('.', function(x)
local r,b='',x:byte()
for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
return r;
end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
if (#x < 6) then return '' end
local c=0
for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
return b:sub(c+1,c+1)
end)..({ '', '==', '=' })[#data%3+1])
end
local Auth = GetAuth(ConsumerKey, SecretKey)
local function GetFollowing(UserId: number, ScreenName: string?, Cursor: string?, Count: number?, SkipStatus: boolean?, IncludeUserEntities : boolean?)
local Parameters = {["user_id"] = UserId, ["screen_name"] = ScreenName, ["cursor"] = Cursor, ["count"] = Count, ["skip_status"] = SkipStatus, ["include_user_entities"] = IncludeUserEntities}
local Url = FillParameters("https://api.twitter.com/1.1/followers/list.json", Parameters)
return HttpService:GetAsync(Url, true, {Authorization = "Bearer " .. Auth)
end
Full code:
local HttpService = game:GetService("HttpService")
local AuthLink = "https://api.twitter.com/oauth2/token"
local ConsumerKey = ""
local SecretKey = ""
local function Encode(data)
-- gotta add in the credits
-- Lua 5.1+ base64 v3.0 (c) 2009 by Alex Kloss <alexthkloss@web.de>
-- licensed under the terms of the LGPL2
local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
return ((data:gsub('.', function(x)
local r,b='',x:byte()
for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
return r;
end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
if (#x < 6) then return '' end
local c=0
for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
return b:sub(c+1,c+1)
end)..({ '', '==', '=' })[#data%3+1])
end
local function FillParameters(Url, Parameters)
local FilledParameters = 0
for Parameter, Filled in pairs(Parameters) do
if Filled then
Url = Url .. (if FilledParameters > 0 then "&" .. Parameter .. "=" else "?" .. Parameter .. "=") .. Filled
FilledParameters += 1
end
end
return Url
end
local function GetAuth(ConsumerKey, SecretKey)
local Data = HttpService:PostAsync(
AuthLink,
"grant_type=client_credentials",
Enum.HttpContentType.ApplicationUrlEncoded,
false,
{Authorization = "Basic " .. Encode(ConsumerKey.. ":" .. SecretKey)} -- WHY DO I HAVE TO ENCODE IT
)
return string.gsub(
HttpService:JSONDecode(Data).access_token,
"%%%x%x",
function(Replacement)
return string.char(tonumber(string.sub(Replacement, 2), 16))
end
)
end
local Auth = GetAuth(ConsumerKey, SecretKey)
local function GetFollowers(UserId: number, ScreenName: string?, Cursor: string?, Count: number?, SkipStatus: boolean?, IncludeUserEntities : boolean?)
local Parameters = {["user_id"] = UserId, ["screen_name"] = ScreenName, ["cursor"] = Cursor, ["count"] = Count, ["skip_status"] = SkipStatus, ["include_user_entities"] = IncludeUserEntities}
local Url = FillParameters("https://api.twitter.com/1.1/followers/list.json", Parameters)
return HttpService:GetAsync(Url, true, {Authorization = "Bearer " .. Auth})
end
it should return like this