Hello Again.
I have this working. After all the frustrations, I ended up deleting everything I had done and started over by copying your files and it worked.
Now, I have another question....
How do you add custom headers to your https requests?
My code looks like this now:
Quote: require "async"
version_url = "https://discordapp.com/api/"
thread = async.request(version_url, "HTTPS")
print("URL:"..version_url)
retval, page, status, headers, full_status = thread:join()
thread = nil
if status == 200 then -- 200 is the HTTP status code for "OK"
print("Status: "..status)
print("Retval: "..tostring(retval))
--print("Page: "..tostring(page))
print("Headers: "..print_r(headers,0))
print("Full_Status: "..full_status)
else
print("Status(F): "..status)
end
and it throws valid errors from the Discord API. I went into https.lua and tried to add this:
Quote: url.headers["Authorization"] = "Bot Mzc0MzI5MjEwNjk4ODU4NDk2.DOJuvQ.vEPpApkI51qgXQeINp7ywqvJol4"
after line 121, but that didn't do anything.
Ironically, the ONLY call that I need to make will be to Discord so if the headers were "hard coded" that would be fine.
I need to do something like this call: (only through https)
Quote: --local request_body = json.encode({email="<<myemail>>", password = "<<mypassword>>"})
--local response_body = {}
--local res, code, response_headers, status = http.request{
-- url = "https://discordapp.com/api/auth/login",
-- headers =
-- {
-- ["Content-Type"] = "application/json",
-- ["Content-Length"] = string.len(request_body),
-- ["Authorization"] = "Bot <<bot token>>";
-- },
-- source = ltn12.source.string(request_body),
-- sink = ltn12.sink.table(response_body),
--}
I'm almost there though. The fact that I get a 200 response from https://www.google.com is great progress!!
Thanks again for the help so far! Once I figure out how to add the custom headers I should be real close to solving my problem! |