Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

HTTP method post only works once before having to reopen Roblox Studio, is this my fault?

Asked by 4 years ago

So I was bored and I was wondering if there were any Snapchat usernames that were a common word left to claim. Here is the code:

http = game:GetService("HttpService")
names = {"hello"}
username = ""
function req()
    local response = http:RequestAsync({
    Headers = {
                Accept = "*/*",
                ["Accept-Language"] = "en-US,en;q=0.5",
                Referer = "https://accounts.snapchat.com/",
                Cookie = "xsrf_token=PlEcin8s5H600toD4Swngg; sc-cookies-accepted=true; web_client_id=b1e4a3c7-4a38-4c1a-9996-2c4f24f7f956; oauth_client_id=c2Nhbg==",
                ["Content-Type"] = "application/x-www-form-urlencoded; charset=utf-8",
            },
    Method = "POST",
    Url = "https://accounts.snapchat.com/accounts/get_username_suggestions?requested_username="..username.."&xsrf_token=PlEcin8s5H600toD4Swngg",
    Body = username
    })
    if response.Success then
        if http:JSONDecode(response.Body).status_code == "TAKEN" then
            return true
        elseif http:JSONDecode(response.Body).status_code == "OK" then
            return false
        else
            return false
        end
    else
        return {code=response.StatusCode,message=response.StatusMessage,body=response.Body}
    end
end
for i=1,#names do
    username = names[i]
    success,err = pcall(req)
    if typeof(err) == typeof({}) then
        print(err.code,err.message,err.body)
    else
        if err then
            print("Taken :(")
        else
            print("Avaliable :)")
        end 
    end
    wait(1)
end

I was testing if it even worked so that's why I don't have a list of words to read yet. Anyway, the code worked only for one word and it never worked again. Even if I reran the script through the command bar it still wouldn't work. The only way I was able to make it work was from closing and reopening Studio. The error that it sent was HTTP 405 Method Not Allowed, HTTP method POST is not supported by this url. This is weird because the first time I used POST it worked, but the second time it didn't. This could be a problem with my code, the website, or Roblox but I'm not sure, any help would be appreciated.

Answer this question