Hey guys, I’ve been working on a WordPress theme for a while now and all works fine when it’s on my server, but when I load it up on my machine locally I am unable to utilise certain functionality, namely the ability to post from outside the admin panel. To do this I use XMLRPC and the following code –
$params = array(0,$username,$password,$content,true);
$request = xmlrpc_encode_request('metaWeblog.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);
$results = curl_exec($ch);
curl_close($ch);
The params passed are all valid and correct, and I just cannot figure out what is wrong for the life of me. Any help would be much appreciated.
Based on your fail point… sounds like your local machine isn’t completely setup. Presumably PHP works if it gets to
xmlrpc_encode_request
before failing, but isphp.ini
setup correctly, and theXML-RPC
library enabled?Update:
You need to remove the semi-colon from the line:
Have you tried seeing what the response from the $results variable is? Is the $rpcurl variable set to the right URL?