Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local HTTPService = game:GetService("HttpService")
- local lockbox = require(script.Parent.lockbox)
- lockbox.bit = require(script.Parent.bit).bit
- local array = require(lockbox.util.array)
- local stream = require(lockbox.util.stream)
- local base64 = require(lockbox.util.base64)
- local hmac = require(lockbox.mac.hmac)
- local sha256 = require(lockbox.digest.sha2_256)
- local secretKey = "16813a12f718bc5c620f56944e1abc3ea13ccbac"
- local function hmacAuthHash(body, key)
- local hmacBuilder = hmac()
- .setBlockSize(64)
- .setDigest(sha256)
- .setKey(array.fromString(key))
- .init()
- .update(stream.fromString(body))
- .finish()
- return base64.fromArray(hmacBuilder.asBytes())
- end
- function Request_Init(endpoint)
- local InitPayload = {
- ["platform"] = "ios",
- ["os_version"] = "ios 8.2",
- ["sdk_version"] = "rest api v2"
- }
- local InitPayloadJSON = HTTPService:JSONEncode(InitPayload)
- local Headers = {
- ["Authorization"] = hmacAuthHash(InitPayloadJSON, secretKey)
- }
- local success, InitResponse = pcall(function() return HTTPService:PostAsync(endpoint,InitPayloadJSON,Enum.HttpContentType.ApplicationJson, false, Headers) end)
- if not success then
- print("PostAsync Error for endpoint",endpoint," ERROR:",InitResponse)
- return
- else
- print("PostAsync Success for endpoint",endpoint," RESPONSE:",InitResponse)
- return
- end
- end
- Request_Init("http://sandbox-api.gameanalytics.com/v2/5c6bcb5402204249437fb5a7a80a4959/init")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement