Help with function please

Discussion in 'PHP' started by deemainer, Oct 10, 2009.

  1. #1
    Hi all,

    I posted previously but probably didnt ask the right way...so here goes. I have this xmlrpc code to post to wordpress, however I think i might be implementing it wrong as i cant get it to work. I have the right stuff enabled in wordpress and i can post using ecto (blog client) so i know the system works.

    Would someone mind giving me an idiot proof instruction on how to call this function correctly ? Would appreciate it greatly.Thanks. Heres the code:

    function wpPostXMLRPC($title,$body,$rpcurl,$username,$password,$categories=array(1)){
    $categories = implode(",", $categories);
    $XML = "<title>$title</title>".
    "<category>$categories</category>".
    $body;
    $params = array('','',$username,$password,$XML,1);
    $request = xmlrpc_encode_request('blogger.newPost',$params);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
    curl_setopt($ch, CURLOPT_URL, $rpcurl);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 1);
    curl_exec($ch);
    curl_close($ch);
    }
    
    Code (markup):
     
    deemainer, Oct 10, 2009 IP