HELP-wordpress cURL psoting articles

maximviper

BANNED
Joined
Oct 25, 2010
Messages
338
Reaction score
87
hello,

I am trying to post article sto my worpress blogs using cURl ,i looked internet and found this code but its not working.. can some please help me fix this code ?


PHP:
    <?php
     
   
    function curlRemotePostToWordPress($url, $login, $pass, $postTitle, $postCats, $postContent) {
            echo "<BR> $pass <BR>";
            // Remote post url
            $rpcUrl = rtrim($url, '/').'/xmlrpc.php';
           
            // Categories for the post
            $categories = explode(',', $postCats);
           
            // Post xml
            $xml = '<title>'.$postTitle.'
             <category>'.$categories.'</category>
             < ![CDATA[ '.$postContent.' ]]>';
     
           
            // Build request
            $params = array('', '', $login, $pass, $xml, 1);
            echo "<BR> $params <BR>";
            $request = xmlrpc_encode_request('blogger.newPost', $params);
           echo $request;
            // Send the request
            try {
           
                    $ch = curl_init();
           
                    // cUrl configuration
                    curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
                    curl_setopt($ch, CURLOPT_URL, $rpcUrl);
                    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                    curl_setopt($ch, CURLOPT_TIMEOUT, 1);
           
                    // Execution
                    curl_exec($ch);
                    curl_close($ch);
           
                    return true;
           
            } catch (Exception $e) {
           
                    return false;
           
            }
    }
     $url="www.xxxxxxxx.com";
     $login="admin";
     $pass="passwrd";
     $postTitle="hello word new";
     $postCats="latest";
     $postContent="This is my new test post";
     
     echo curlRemotePostToWordPress($url, $login, $pass, $postTitle, $postCats, $postContent);
     

    ?>


i enabled xmlrpc in my wordpress blog.but still i m not able to post.
 
never mind . fixed it myself. lemme know if anyone needs it :)
 
Just wondering if you could PM me or post up the final PHP code for posting to my "wordpress" blog please, i have a bot that will leech from RSS feeds, download the links, do all of my processes re upload and then et the post info i just dont have the auto post to wordpress
 
Back
Top