clementyu Posted February 3, 2011 Share Posted February 3, 2011 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 Quote Link to comment Share on other sites More sharing options...
clementyu Posted February 4, 2011 Author Share Posted February 4, 2011 :'( Sorry to bother this question again anyone has any ideas? thanks so much Quote Link to comment Share on other sites More sharing options...
artur.kaze Posted February 4, 2011 Share Posted February 4, 2011 Did you debug your file? Post output too. Quote Link to comment Share on other sites More sharing options...
clementyu Posted February 5, 2011 Author Share Posted February 5, 2011 Debug result ( ! ) Fatal error: Maximum execution time of 30 seconds exceeded in D:\Website\Web_Robot\Login\Snoopy.class.php on line 849 Call Stack # Time Memory Function Location 1 0.0013 343328 {main}( ) ..\login_wordpress_post.php:0 2 29.1263 695704 Snoopy->submit( string(44), array(25), ??? ) ..\login_wordpress_post.php:73 3 29.1677 697392 Snoopy->_httprequest( string(28), resource(6, stream), string(44), string(4), string(33), string(656) ) ..\Snoopy.class.php:306 Quote Link to comment Share on other sites More sharing options...
clementyu Posted February 6, 2011 Author Share Posted February 6, 2011 If I cannot get the answer from this forum, from where I might possibly find the answer? thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.