Introduce yourself here! In order to avoid spam, new users must first comment on the discussion in the 'Introductions' before they become 'full members'
Howto get _wpnonce and _wp_http_referer Value?
  • Hi,

    i writing a linux shell script to automatically add a new entry to flatpress.

    here is the script (a first attempt):
    [code]
    #!/bin/bash

    fp_url="http://example.net"
    fp_user="***"
    fp_pass="***"

    set -e
    set -x

    cookie="$(mktemp)"
    trap "rm -f -- '$cookie'" EXIT INT

    # Login
    post_data="user=${fp_user}&pass=${fp_pass}"
    wget --save-cookies "$cookie" --keep-session-cookies --post-data="$post_data" -O "/dev/null" "${fp_url}/login.php"

    # Get _wpnonce and _wp_http_referer Value
    _wpnonce="$(wget --load-cookies "$cookie" --keep-session-cookies -O "/dev/stdout" "$fp_url/admin.php?p=entry&action=write" | grep -Eo '' | sed 's/^//')"
    _wp_http_referer=""

    # Post the Article
    post_data="_wpnonce=$_wpnonce&_wp_http_referer=$_wp_http_referer&attachselect=--&cats[16]=on&cats[21]=on&content=bar&entry=&flags[draft]=on&imageselect=--&save=Publish&subject=foo&timestamp="
    wget --load-cookies "$cookie" --keep-session-cookies --post-data="$post_data" -O "/dev/stdout" "$fp_url/admin.php?p=entry&action=write"
    [code]

    Is there a better way to get the _wpnonce value?

    Thx,
    inne
Start a New Discussion

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!