XML-RPC: Getting category list from a wordpress site with xml-rpc

How we can get categeroy of wordpress site by xml-rpc.
i now that we need to use username and pass to connect to the site.

set_time_limit(0);
include("xmlrpc.inc"); 
$GLOBALS['xmlrpc_internalencoding'] = 'UTF-8';
define ('DOMAIN', 'abc.com'); // wordpress server
define ('BLOGID', 1); 
define ('USER', 'admin'); // wordpress admin account
define ('PASSWORD', 'pass'); // wordpress password

How i will continue to get the category list?

Read More

how i will use wp.getCategories class?
i have a code like this i do not know it is good or not

$categories = $wp->getCategoriesEx($blogID = 1);

thanks

Related posts

Leave a Reply

1 comment

  1. Based on my own code…

    class WpXmlRpc {
        private $XmlRpcURL;
        private $UserName;
        private $PassWord;
    
        public function __construct($xmlrpcurl, $username, $password) {
            $this->XmlRpcURL = $xmlrpcurl;
            $this->UserName  = $username;
            $this->PassWord = $password;
        }
    
        private function send_request($requestname, $params) {
            $request = xmlrpc_encode_request($requestname, $params);
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
            curl_setopt($ch, CURLOPT_URL, $this->XMLRPCURL);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_TIMEOUT, 1);
            $results = curl_exec($ch);
            curl_close($ch);
            return $results;
        }
    
        public function getCategories() {
            $params = array();
            return $this->send_request('wp.getCategories', $params); // your results!
        }
    }
    

    Your result will be an array something like this…

    Array(
        'Request Name' => 'wp.getCategories',
        'Result' => Array(
            'category',
            'category',
            'category'
        )