1

I've recently tried to use the following code to send paste to pastebin.com:

https://github.com/mefuckin/pastebin-shell/blob/master/pbin

What I've noticed with that script is that it doesn't appear to send api_user_key. Line 183 has it listed:

--data "api_user_key=$api_user_key" \ 

so I though it would just be a matter of specifying its value, as:

api_user_key="VALUE HERE" 

and that would send it to the API. However, I'm unsure of what that part of the code does (part of code that starts at 174):

[ $logintopastebin -ne 0 ] && auth_user api_paste_code=$( cat - ) curl -0 --show-error \ --data "api_dev_key=$api_dev_key" \ --data "api_option=paste" \ --data "api_paste_code=$api_paste_code" \ --data "api_paste_format=$api_paste_format" \ --data "api_paste_private=$api_paste_private" \ --data "api_paste_expire_date=$api_paste_expire_date" \ --data "api_user_key=$api_user_key" \ --data-urlencode "api_paste_name=$api_paste_name" \ --data-urlencode "api_paste_code=$api_paste_code" \ "$api_url/api_post.php" 

Does this portion of the code mean that all these arguments will be sent to the API?

1 Answer 1

0

The code does send the api_user_key. It may send an empty string if the variable is not set. The script contains code to find the user key by querying the server in the function auth_user, but that function is only called if you set logintopastebin to a nonzero value at the beginning or if you pass one of the options -u or -l on the command line. You can override the value by setting the variable api_user_key manually after or instead of the call to auth_user, before the call to curl, e.g.

api_user_key=$(cat ~/.passwords/pastebin/api_user_key) … if [ -z "$api_user_key" ] && [ "$logintopastebin" -eq 0 ]; then auth_user fi api_paste_code=$( cat - ) curl -0 --show-error \ … 

If you don't understand what the script is doing, add set -x as the second line to make it print a trace of each line as it gets executed.

2
  • Thank you! It appears that even though I am setting api_user_key and even though I'm setting both -u and -l, the API still isn't recognising it, as it doesn't allow me to perform the requests that are tied to the api_user_key. Maybe that's something for pastebin.com ... :/ Commented Apr 9, 2017 at 16:41
  • Disregard my last comment. Using the code you supplied and setting up api_user_key definitely worked and the "privileges" that are given via it were applied. Thank you. Commented Apr 9, 2017 at 17:11

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.