1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

HELP-wordpress cURL psoting articles

Discussion in 'PHP & Perl' started by maximviper, Apr 17, 2011.

  1. maximviper

    maximviper BANNED BANNED

    Joined:
    Oct 25, 2010
    Messages:
    338
    Likes Received:
    86
    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$xml1);
                echo 
    "<BR> $params <BR>";
                
    $request xmlrpc_encode_request('blogger.newPost'$params);
               echo 
    $request;
                
    // Send the request
                
    try {
               
                        
    $ch curl_init();
               
                        
    // cUrl configuration
                        
    curl_setopt($chCURLOPT_POSTFIELDS$request);
                        
    curl_setopt($chCURLOPT_URL$rpcUrl);
                        
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
                        
    curl_setopt($chCURLOPT_TIMEOUT1);
               
                        
    // 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.
     
  2. maximviper

    maximviper BANNED BANNED

    Joined:
    Oct 25, 2010
    Messages:
    338
    Likes Received:
    86
    never mind . fixed it myself. lemme know if anyone needs it :)
     
  3. brianpirouet

    brianpirouet Newbie

    Joined:
    Jul 19, 2011
    Messages:
    3
    Likes Received:
    0
    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
     
  4. ajtdmw1

    ajtdmw1 Newbie

    Joined:
    Jul 13, 2011
    Messages:
    5
    Likes Received:
    0
    can you also pm me ?