Jump to content

How to auto login and post in wordpress by php snoopy or curl ?


clementyu

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.