notes/Patreon Posting Script-bnxSh5YA.sh
#!/bin/bash


if [ $# -lt 2 ]
then
  echo "Usage: $0 '<title>' '<text>'"
  exit
fi

title=$1
text=$2

email="<email>"
password="<password>"

echo "Login part 1..."
curl -c cookie 'https://api.patreon.com/login' -X OPTIONS -H 'access-control-request-headers: accept, content-type' -H 'access-control-request-method: POST' -H 'origin: https://www.patreon.com' -H 'accept-encoding: gzip, deflate, sdch' -H 'accept-language: en-US,en;q=0.8' -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36' -H 'accept: */*' -H 'referer: https://www.patreon.com/login?ru=%2Fmetalx1000%3Fty%3Dh' --compressed

echo "Login part 2..."
curl -b cookie  -c cookie 'https://api.patreon.com/login' -H 'origin: https://www.patreon.com' -H 'accept-encoding: gzip, deflate' -H 'accept-language: en-US,en;q=0.8' -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36' -H 'content-type: application/json'  --data-binary "{\"data\":{\"email\":\"$email\",\"password\":\"$password\"}}" --compressed

echo "Getting new post id..."
id="$(curl -s -b cookie "https://api.patreon.com/posts/new"|grep embed -A 1|grep id|head -n 1|cut -d\" -f4)"
echo "ID is $id"

echo "Creating new post..."
curl -b cookie "https://api.patreon.com/posts/$id?fields\[post\]=post_type,title,content,comment_count,min_cents_pledged_to_view,like_count,post_file,image,thumbnail,embed,is_paid,is_automated_monthly_charge,published_at,url,pledge_url,current_user_has_liked&include=null" -H 'origin: https://www.patreon.com' -H 'accept-encoding: gzip, deflate' -H 'accept-language: en-US,en;q=0.8' -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36' -H 'content-type: application/json' -H 'accept: application/json, text/plain, */*' -H 'referer: https://www.patreon.com/post' --data-binary "{\"data\":{\"id\":\"$id\",\"campaign_id\":\"83784\",\"title\":\"$title\",\"content\":\"<p>$text</p>\",\"embed\":{\"html\":null},\"tags\":{\"publish\":true},\"post_file\":null,\"thumbnail\":null,\"thumbnails\":[],\"post_type\":\"text_only\",\"is_paid\":false,\"category\":\"1\",\"min_cents_pledged_to_view\":0}}" --compressed
#curl -b cookie "https://api.patreon.com/posts/$id?fields\[post\]=post_type,title,content,comment_count,min_cents_pledged_to_view,like_count,post_file,image,thumbnail,embed,is_paid,is_automated_monthly_charge,published_at,url,pledge_url,current_user_has_liked&include=null" -H 'origin: https://www.patreon.com' -H 'accept-encoding: gzip, deflate' -H 'accept-language: en-US,en;q=0.8' -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36' -H 'content-type: application/json' -H 'accept: application/json, text/plain, */*' -H 'referer: https://www.patreon.com/post' --data-binary "{'data':{'id':'$id','campaign_id':'83784','title':'$title','content':'<p>$text</p>','embed':{'html':null},'tags':{'publish':true},'post_file':null,'thumbnail':null,'thumbnails':[],'post_type':'text_only','is_paid':false,'category':'1','min_cents_pledged_to_view':0}}" --compressed

syntax highlighted by Code2HTML, v. 0.9.1