Blog Posting

XML Remote Procedure Calls mimics how traditional function calls are made because the name of the method and individual parameters are wrapped in an XML. WordPress offers the capability to automatically post using XML RPCs.

The PHP code below demonstrates how the method name ($requestname) and the parameters ($params) can be encoded into an XML file and sent to WordPress:


    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;
    }
Enter the post contents