Created
January 21, 2018 11:30
-
-
Save YuzuRyo61/6388e6e8bde15712348e95714c82b0e1 to your computer and use it in GitHub Desktop.
curlでmastodonの投稿APIを叩くだけのスクリプト。整備がとても荒いと思います。ですがふつーに使うのであれば問題ない・・・と思う。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Setting | |
ACCESS_TOKEN="CHANGE_HERE" | |
INSTANCE_ADDRESS="CHANGE_HERE" | |
# === There are system scripts. if you are not familiar the bash script, Please do not edit their scripts. === | |
SETINC=0 | |
if [ $ACCESS_TOKEN = "CHANGE_HERE" ]; then | |
echo "Please edit ACCESS_TOKEN." | |
SETINC=1 | |
fi | |
if [ $INSTANCE_ADDRESS = "CHANGE_HERE" ]; then | |
echo "Please edit INSTANCE_ADDRESS." | |
SETINC=1 | |
fi | |
if [ $SETINC != 0 ]; then | |
exit 1 | |
fi | |
echo "Checking address... :" $INSTANCE_ADDRESS | |
curl https://$INSTANCE_ADDRESS/ >/dev/null 2>&1 | |
case $? in | |
0) | |
;; | |
6) | |
echo "[ERROR] Can't resolve " $INSTANCE_ADDRESS ". Are you connected to the network or are you using the wrong address?" | |
exit 1 | |
;; | |
127) | |
echo "[ERROR] curl package is not found. please install curl package." | |
exit 1 | |
;; | |
*) | |
echo "[ERROR] An unknown error occurred." | |
exit 1 | |
;; | |
esac | |
echo "What are you doing now?" | |
echo -n "$ " | |
read statuses | |
curl -X POST -d "status=$statuses" --header "Authorization: Bearer $ACCESS_TOKEN" -sS https://$INSTANCE_ADDRESS/api/v1/statuses; echo $? | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
使い方
注意