Support » Fixing WordPress » XML-RPC and cURLS

  • Resolved ale.sasha


    Since I’m not able to edit php.ini file on my hosting service, I need to use cURL without the xmlrpc_encode_request() PHP function, and I’m trying to pass the XML request whithout using such function.
    So, I’ve activated XML-RPC from WP Administration Panel, I’ve activated cURL from my hosting service administration page, and I’m using the following code:


    function wpPostXMLRPC($title,$body,$rpcurl,$username,$password,$category,$keywords=”,$encoding=’UTF-8′) {
    $title = htmlentities($title,ENT_NOQUOTES,$encoding);
    $keywords = htmlentities($keywords,ENT_NOQUOTES,$encoding);
    $ch = curl_init();
    $curlStr=”<?xml version=\”1.0\” encoding=\”iso-8859-1\”?><methodCall><methodName>metaWeblog.newPost</methodName><params>”.
    “<param><value><string><title> TITOLO </title><category> CATEGORIA </category> BODY </string></value></param>”.

    curl_setopt($ch, CURLOPT_URL, $rpcurl);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 1);
    $results = curl_exec($ch);
    return $results;

    but it seems to be wrong: I get the following error:
    Warning: curl_error(): supplied argument is not a valid cURL handle resource in …

    How can I fix It, please?
    Thank you,

Viewing 9 replies - 1 through 9 (of 9 total)
  • Check to see if you got a valid resource back from curl_init().

    Also XML-RPC is a lot easier if you just use one of the PHP libraries for it. WordPress uses IXR, works well.

    curl_init give me a valid resource, so it is ok. The problem is on the XML string I pass to curl_exec throug $ch, but I don’t know how pass it correctly.

    I’d really like to use a PHP library for XML-RPC, but, which one can be used whithout editing php.ini?

    Thank you,

    This is the XML I pass to the curl_exec();

    <?xml version=”1.0″ encoding=”iso-8859-1″?>
    <title> TITOLO </title>
    <description> DESC </description>

    Is it right for WordPress?
    Thank you,

    You can use the IXR library without touching the php.ini file.

    Ok, thank you.
    With IXR Lib, how should I pass parameters? Is there some example written for wordpress posting through xml-rpc?

    A simple XML-RPC client example is available in IXR docs –



    Hi Scott,
    Is there a way to detect duplicate posts or pages when using IXR xmlrpc to post ?

    Joseph Scott


    If I understand your question correctly, no, the XML-RPC API doesn’t try to detect duplicate posts. If you tell it that what you sent is a new post, it will treat it as a new post.



    Thanks Scott, I am trying to make sure that I don’t post the same page/post more than once. WP happily creates a new URL for the same content when I try to post with IXR/XMLRPC.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘XML-RPC and cURLS’ is closed to new replies.