Rahph

pbapi

Jun 10th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.70 KB | None | 0 0
  1. function get(code)
  2.     local val= {}
  3.     local httphandle = http.get("https://pastebin.com/raw/"..code)
  4.     if not httphandle then
  5.         val.status = "failure"
  6.         val.content = "The PastebinApi failed to download the file. If you see this, that means something is terribly wrong with the program utilising my API."
  7.     else
  8.         val.status = "fetched"
  9.         val.content = httphandle.readAll()
  10.     end
  11.     return val
  12. end
  13.  
  14. function login(username,password)
  15.     local val = {}
  16.     local devkey = "b25628a557387174679205df2dea582c"
  17.     local statement = "api_dev_key="..devkey.."&api_user_name="..username.."&api_user_password="..password
  18.     local response = http.post("https://pastebin.com/api/api_login.php",statement).readAll()
  19.     if response == "Bad API request, invalid login" then
  20.         val.status = "BadLogin"
  21.     elseif response == "Bad API request, account not active" then
  22.         val.status = "AccInactive"
  23.     else
  24.         val.status = "Fine"
  25.         val.key = response
  26.     end
  27.     return val
  28. end
  29.  
  30. function putAsGuest(content,title)
  31.     local val = {}
  32.     local devkey = "b25628a557387174679205df2dea582c"
  33.     local statement = "api_dev_key="..devkey.."&api_option=paste&api_paste_code="..content.."&api_paste_format=lua&api_paste_expire_date=N&api_paste_name="..title
  34.     response = http.post("http://pastebin.com/api/api_post.php",statement).readAll()
  35.     print(response)
  36. end
  37.  
  38. function putAsUser(content,title,userkey)
  39.     local val = {}
  40.     local devkey = "b25628a557387174679205df2dea582c"
  41.     local statement = "api_dev_key="..devkey.."&api_option=paste&api_paste_code="..content.."&api_paste_format=lua&api_paste_expire_date=N&api_paste_name="..title.."&api_user_key="..userkey
  42.     response = http.post("http://pastebin.com/api/api_post.php",statement).readAll()
  43.     print(response)
  44. end
Add Comment
Please, Sign In to add comment