I am trying to use WordPress XML-RPC. I found that by default XMLRPC will be enabled in my version of WordPress (3.9.1). But when I am trying to run the below PHP code, the following error is being displayed:
Fatal error: Call to undefined function xmlrpc_encode_request() in /Applications/XAMPP/xamppfiles/htdocs/easyblog/test/hellotest.php on line 6
Here is my PHP code.
<?PHP
//XML RPC Test
define('RPC_URL', 'http://localhost/wordpress/xmlrpc.php');
function sendRequest($methodName, $parameters)
{
$request = xmlrpc_encode_request($methodName, $parameters);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_URL, RPC_URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
$results = curl_exec($ch);
$results = xml_decode($results);
curl_close($ch);
return $results;
}
$parameters = array();
$response = sendRequest('demo.sayHello', $parameters);?>
Server Details:
I am using XAMPP server with PHP 5.5.11 on Mac OS X.
When I Googled this error I found that we need to enable XML-RPC in XAMPP php configuration file. So in XAMPP php.ini file I have uncommented extension=php_xmlrpc.dll
and restarted the server and checked. But again I am getting the same error.