Skip to content

Instantly share code, notes, and snippets.

@koddsson koddsson/n
Created Jun 26, 2019

What would you like to do?
Simple Bash script that let's me post a micropub note from my terminal
#! /bin/bash
CODE=$(cat token)
STATUS_CODE=$(curl -sw '%{http_code}' -o /dev/null -d "code=$CODE&redirect_uri=$ME"
if [ $STATUS_CODE -eq 404 ]; then
open "$ME&client_id=$ME&scope=create+update&response_type=code&"
echo "You need to get a new token"
exit 1
ACCESS_TOKEN=$(curl -s -H 'Accept: application/json' "" -d "code=$CODE&redirect_uri=$ME&me=$ME" | jq -r '.access_token')
curl -s -H "Authorization: Bearer $ACCESS_TOKEN" -d "h=entry&content=$1" $MICROPUB_ENDPOINT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.