Forums

How to add tags when posting via PHP (1 post)

  1. Amusesmile
    Member
    Posted 9 months ago #

    Hey, I'm trying to figure out how to add tags/keywords (these terms are interchangeable, right?) when posting to my blog via PHP. Here is the function I'm using to post right now. It's working great, but I want to programmatically add tags. Many thanks:

    <?php
    //DEFINE
    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);
    }
    //START
    wpPostXMLRPC("May 14, 2011",allMyHTMLGoesHere,"http://thisiswhatwecareabout.com/xmlrpc.php",admin,fakePassword);

Reply

You must log in to post.

About this Topic