commit 3207d2ac4e49a6ecf7913e5320735c0eb060aa9a Author: Gandalf Date: Thu Mar 4 17:51:36 2021 +0100 push to remote diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/Testfax.pdf b/Testfax.pdf new file mode 100644 index 0000000..d9add10 Binary files /dev/null and b/Testfax.pdf differ diff --git a/skript.sh b/skript.sh new file mode 100755 index 0000000..e8d6a05 --- /dev/null +++ b/skript.sh @@ -0,0 +1,21 @@ +#! /bin/bash + +FILE=$1 +echo $FILE +REC=$(sed 's/^0/+49/' $2) +. login_credentials.sh +AUTH_TOKEN=$(echo $(curl --request POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' --data-urlencode client_id=sipgate-app-web --data-urlencode grant_type=password --data-urlencode username=$SIPUSER --data-urlencode password=$SIPPWD https://api.sipgate.com/login/sipgate-apps/protocol/openid-connect/token -s | jq '.access_token') | sed 's/\"//g') +if [ -z "$AUTH_TOKEN" ]; +then + echo "Login failed" +else + echo "Logged in" +fi +CONTENT=$(base64 $FILE -w 0) +#echo "$CONTENT" +DATA='{"faxlineId":"f0", "recipient":"+495512829364", "filename":"fax.pdf", "base64Content":"'${CONTENT}'"}' +#echo "$DATA" +curl -i --request POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header "Authorization: Bearer $AUTH_TOKEN" --data "$DATA" "https://api.sipgate.com/v2/sessions/fax" -s +echo +curl --request GET --header 'Content-Type: application/json' --header 'Accept: application/json' --header "Authorization: Bearer $AUTH_TOKEN" "https://api.sipgate.com/v2/history" -s | jq +curl --request GET --header 'Content-Type: application/json' --header 'Accept: application/json' --header "Authorization: Bearer $AUTH_TOKEN" "https://api.sipgate.com/v2/balance" -s | jq