Wordpress CURL login not working -


i had curl script wordpress blog started failing. error message cookies must enabled login. below code logging in.

$post_str = 'log=username&pwd=password&redirect_to=https://sub.wordspress.com/wp-admin/&testcookie=1&wp-submit=log%20in'; $cookie = tempnam ("/tmp", "curlcookie"); $url = "https://domain.com/wp-login.php"; $ch = curl_init(); curl_setopt ($ch, curlopt_url, $url); curl_setopt ($ch, curlopt_ssl_verifypeer, false); curl_setopt ($ch, curlopt_useragent, "mozilla/5.0 (windows; u; windows nt 5.1; en-us; rv:1.8.1.6) gecko/20070725 firefox/2.0.0.6"); curl_setopt ($ch, curlopt_timeout, 60); curl_setopt ($ch, curlopt_cookiejar, $cookie); curl_setopt ($ch, curlopt_referer, 'https://sub.wordpress.com/wp-admin/'); curl_setopt ($ch, curlopt_post, 1); curl_setopt ($ch, curlopt_postfields, $post_str); curl_setopt($ch, curlopt_cookiesession, true); curl_exec ($ch); curl_close($ch); 

cookie file:

# netscape http cookie file # http://curl.haxx.se/rfc/cookie_spec.html # file generated libcurl! edit @ own risk.  .wordpress.com  true    /   false   0   wordpress_test_cookie   wp+cookie+check 

any ideas?

ok, maybe have answer.

my (bash) script stopped working doesn't yours.

here mine originally, not working after 8/23:

# set default file names... cookies="$filepath/cookies.txt"  # set login data postdata="log=${username}&pwd=${password}" postdata="${postdata}&rememberme=forever&submit=log%20in" postdata="${postdata}&redirect_to=http://wordpress.com/&testcookie=1"  #first test cookie curl --silent --cookie-jar "${cookies}" --output /dev/null "${login_url}"  # log in curl --silent \     --cookie-jar "${cookies}" \     --output /dev/null \     --max-redirs 0 \     --data "${postdata}" \     "${login_url}" 

all took fix addition of cookie parameter in second curl call this:

curl --silent \     --cookie "${cookies}" \     --cookie-jar "${cookies}" \     --output /dev/null \     --max-redirs 0 \     --data "${postdata}" \     "${login_url}" 

not sure 100% looks in context of script, maybe adding line this:

curl_setopt ($ch, curlopt_cookie, $cookie);

would it?


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -