views:

17

answers:

2

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.

A: 

Have you tried seeing what the response from the $results variable is? Is the $rpcurl variable set to the right URL?

Sasha
Hey thanks for the quick response, but the page appears to die after xmlrpc_encode_request() is called, therefore I am unable to view the contents of that variable.
Tom Walters
A: 

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 is php.ini setup correctly, and the XML-RPC library enabled?

Update: You need to remove the semi-colon from the line:

extension=php_xmlrpc.dll
Rudu
How would I go about altering that? I set up a PHP info file and couldn't find 'XML-RPX' anywhere.
Tom Walters
Tom! Sorry, typo... `XML-RPC` library (fixed) + added the extension line from your `php.ini`
Rudu