问题描述:

Currently I can use php snoopy class to auto login in wordpress, but when I try to use the same method to post some articles in wordpress. It does not work. Any one has any ideas?

I have tried to use httpwatch to monitor the post data and cookies. It seems I have include everything, but still doesn't work.

thanks very much. This really driving me crazy.

<?php

include "Snoopy.class.php";

$snoopy = new Snoopy;

//login part

$submit_url = "http://localhost/wordpress/wp-login.php";

$submit_vars["log"] = "baibai"; //username

$submit_vars["pwd"] = "123456"; //password

$submit_vars["rememberme"] = "forever";

$submit_vars["redirect_to"] = "http://localhost/wordpress/wp-admin/";

$submit_vars["testcookie"] = "1";

$submit_vars["wp_sumbit"] = "submit";

$snoopy->submit($submit_url,$submit_vars);

print $snoopy->results;

$snoopy->setcookies();

$cookies = $snoopy->cookies;

print_r ($cookies);

//above part runs perfectly

//post

$snoopy->fetchform("http://localhost/wordpress/wp-admin/press-this.php");

print $snoopy->results;

preg_match('/name=\"_wpnonce\" value=\"([0-9a-z]+)/',$snoopy->results,$matches);

print $submit_vars1["_wpnonce"] = $matches[1];

$submit_vars1["autosave"] = "";

$submit_vars1["newtag[post_tag]"] = "";

$submit_vars1["tax_input[post_tag]"] = "";

$submit_vars1["autosave"] = "";

$submit_vars1["title"] = "title";

$submit_vars1["content"] = "content this is what i want post in wordpress";

$submit_vars1["original_post_status"] = "draft";

$submit_vars1["prev_status"] = "draft";

$submit_vars1["post_type"] = "text";

$submit_vars1["publish"] = "发布";

$submit_vars1["_wp_http_referer"] = "/wordpress/wp-admin/press-this.php?u=http%3A%2F%2Flocalhost%2Fwordpress%2Fwp-admin%2Ftools.php&t=%E5%B7%A5%E5%85%B7%20%E2%80%B9%20ekeyvision%20%E2%80%94%20WordPress&s=&v=4";

$submit_url1 = "http://localhost/wordpress/wp-admin/press-this.php?action=post";

$snoopy->submit($submit_url1,$submit_vars1);

print $snoopy->results;

?>

Also I do not want to use XML-RPC to solve this issue, since xml-rpc are not available is some settings.

thanks

相关阅读:
Top