httpluapastebin

Edit an existing Pastebin document via API


I am trying to write a function in LUA to edit my pastebin code.

I can use this code to make a HTTP post:

http.post(string url, string postData [, table headers])

I can also use this code for a HTTP get:

http.get(string url [, table headers])

on the Pastebin website https://pastebin.com/api are information about using the API. I am not sure, if this website can help me to solve my problem.

Does someone know how to fill the headers table?

this is the program i tried:

headers = {}
headers["api_dev_key"]= 'myDevKey...'; // your api_developer_key
headers["api_paste_code"]   = 'my edited text'; // your paste text
headers["api_paste_private"] = '0'; // 0=public 1=unlisted 2=private
headers["api_paste_name"] = 'justmyfilename.php'; // name or title of your paste
headers["api_paste_expire_date"] = '10M';
headers["api_paste_format"] = 'php';
headers["api_user_key"] = ''; // if an invalid or expired api_user_key is used, an error will spawn. If no api_user_key is used, a guest paste will be created
headers["api_paste_name"] = myPastebinName;
headers["api_paste_code"] = myPastebinPassword;
http.get("https://pastebin.com/edit/dQMDfbkM", headers)

unfortunately this is not working and on the pastebin API help site is no exsample for editing a paste. just for creating a new one.

for me it is also not clear if I have to use post or get


Solution

  • There is no API for editing pastes directly.

    You can only delete old paste and create new with updated text.