Hallo miteinander,
um das Thema abzuschliessen und falls es jemanden interessiert:
Unter der Annahme, dass das JWT-Auth Plugin in der WP-Instanz installiert/konfiguriert/aktiviert und auf der lokalen Maschine das super Tool jq vorhanden ist, geht's wie folgt:
Code
# Set some variables:
WP_URL=...
WP_USERNAME=...
WP_PASSWORD=...
# Page id to modify
PAGE_ID=7
# Get Bearer token:
TOKEN=$(curl -s -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' --data "{\"username\":\"${WP_USERNAME}\", \"password\":\"${WP_PASSWORD}\",\"rememberMe\":false}" ${WP_URL}/wp-json/jwt-auth/v1/token | jq -r '.data.token')
# Get content into temp file:
curl -H 'Accept: application/json' -H "Authorization: Bearer ${TOKEN}" ${WP_URL}/wp-json/wp/v2/posts/${PAGE_ID} | jq '{content: .content.rendered}' > content.json
# Modify content.json to your needs here...
# Update webpage with new content:
curl -X POST -H 'Content-Type: application/json' -H "Authorization: Bearer ${TOKEN}" ${WP_URL}/wp-json/wp/v2/posts/${PAGE_ID} -d @content.json | jq -r '.content.rendered'
Alles anzeigen