How would I go about making a twitter verification system using HTTP service?
How exactly are you planning on using the Twitter verification system in games?
I know of a Game that did that, it’s Lumber Tycoon 2 by @Defaultio, I’ll link the wiki page here
The user will follow my games twitter, type in there username, and if there following us they will get a in-game perk.
Based on Twitter’s Developer Portal, you’ll be able to register for a free account under their services. From there, there should be a project that is automatically created upon registration. Go to the project’s dashboard, and click on the key icon. You’ll need to register an API key alongside its secret and a bearer token is most likely needed. Once you have those, then you just need to send a request with the bearer token and API key/secret as headers! I’m sure there’s documentation to explain it on Twitter, but don’t be afraid to ask for more help.
here is how you do it according to the api
local HttpService = game:GetService("HttpService")
local Link = "https://api.twitter.com/2/users/%s/following"
local Username = ""
local BearerToken = "" -- required
local ApiKey = "" -- required
local ApiKeySecret = "" -- required also
local AccessToken = ""
local AccessTokenSecret = ""
local UserId = HttpService:JSONDecode(HttpService:RequestAsync({Url = "https://api.twitter.com/2/users/by/username/" .. Username, Method = "GET", Headers = {["bearer_token"] = BearerToken, ["api_key"] = ApiKey, ["api_key_secret"] = ApiKeySecret}}))["data"]["id"]
local function IsFollowing(TargetName)
local TargetId = HttpService:JSONDecode(HttpService:RequestAsync({Url = "https://api.twitter.com/2/users/by/username/" .. TargetName, Method = "GET", Headers = {["bearer_token"] = BearerToken, ["api_key"] = ApiKey, ["api_key_secret"] = ApiKeySecret}))["data"]["id"]
local Response = HttpService:JSONDecode(HttpService:RequestAsync({
Url = string.format(Link, UserId),
Method = "POST",
Headers = HttpService:JSONEncode({
["target_user_id"] = TargetId,
["bearer_token"] = BearerToken,
["api_key"] = ApiKey,
["api_key_secret"] = ApiKeySecret
})
}))
return Response['data']['following']
end
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.