· 5 years ago · Oct 25, 2020, 11:06 AM
1local HttpService = game:GetService("HttpService")
2
3local URL_PASTEBIN_NEW_PASTE = "https://pastebin.com/api/api_post.php"
4local dataFields = {
5 -- Pastebin API developer key from
6 -- https://pastebin.com/api#1
7 ["api_dev_key"] = "7469e63a16ece9cd187adb113e8c6b0f";
8
9 ["api_option"] = "paste"; -- keep as "paste"
10 ["api_paste_name"] = "HttpService:PostAsync"; -- paste name
11 ["api_paste_code"] = "Hello, world"; -- paste content
12 ["api_paste_format"] = "text"; -- paste format
13 ["api_paste_expire_date"] = "10M"; -- expire date
14 ["api_paste_private"] = "0"; -- 0=public, 1=unlisted, 2=private
15 ["api_user_key"] = ""; -- user key, if blank post as guest
16}
17
18-- The pastebin API uses a URL encoded string for post data
19-- Other APIs might use JSON, XML or some other format
20local data = ""
21for k, v in pairs(dataFields) do
22 data = data .. ("&%s=%s"):format(
23 HttpService:UrlEncode(k),
24 HttpService:UrlEncode(v)
25 )
26end
27data = data:sub(2) -- Remove the first &
28
29-- Here's the data we're sending
30print(data)
31
32-- Make the request
33local response = HttpService:PostAsync(URL_PASTEBIN_NEW_PASTE, data, Enum.HttpContentType.ApplicationUrlEncoded, false)
34-- The response will be the URL to the new paste (or an error string if something was wrong)
35print(response)