Posted 24 May 2014 - 07:29 PM
Pastebin API
Hello everyone!
I noticed the other day that nobody has every actually made a pasteAPI.
Now I know you might be thinking "Whats the point, this is super easy to make? etc."
Well, based on the amount of time this has been googled by newbies (including myself a while back), I decided to create this. And besides, it took me like a minute and a half.
Use this like any other API on the planet. If you don't know how to do this, see here!
Downloads –> Pastebin, Hastebin
Or run this command in your computer: pastebin get cSs6Pr4p pasteapi
UPDATES:
1: Fixed tabbing on the pastebin link… can't fix it in hastebin *sadface*
2: Fixed the hastebin tabbing *very happy face*
3: Added "upload" function.
Documentation:
Downloader
When using the downloading function these codes may be returned:
11 - The HTTP API is not enabled on your computer.
12 - The file you are attempting to save to exists.
13 - Could not connect to pastebin. The users internet may be down, or pastebin could be down
2 - Success! Download was completed!
Here's some code demonstrating these:
os.loadAPI("pasteapi")
a = pastebin.download("cSs6Pr4p", "paste")
-- Return codes:
if a == 11 then
print("HTTP API not enabled. Aborting...")
elseif a == 12 then
fs.delete("paste")
elseif a == 13 then
print("Something went wrong")
else
print("Yay! Paste was downloaded.")
end
Uploader:
Potential returns:
111 - HTTP API is not enabled.
112 - Attempted to upload a directory
113 - File does not exist
114 - Could not connect.
<code> - Upload success! Pastebin code is: <code>
Here's a way of implementing this.
os.loadAPI("pasteapi")
a = pastebin.upload("test", "This is a test savename")
if not a == 111 then
if not a == 112 then
if not a == 113 then
if not a == 114 then
print(a)
else
print("114")
end
else
print("113")
end
else
print("112")
end
else
print("111")
end
Happy crafting!</code>
</code>
Edited on 25 May 2014 - 11:31 AM