Hi there,
please find hereafter an example of consuming XML RPC API with PHP. It is based on the XML-RPC3.0.0beta downloaded on sourceforge.
You have to modify fields written in Capital letters.
$sLibPath = dirname(__DIR__)."/lib"; $sPath = $sLibPath.'/xmlrpc.inc'; require_once($sPath); // https://www.wikidot.com/xml-rpc-api.php $sServerPath = "xml-rpc-api.php"; $sServerHostName = "www.wikidot.com"; $iServerPort = ""; $oClient = new xmlrpc_client($sServerPath,$sServerHostName,$iServerPort); $oClient->setCredentials("YOUR_WIKIDOT_USERNAME","YOUR_API_KEY"); $oClient->setDebug(2); // Debugging level $oClient->setSSLVerifyPeer(false); $oClient->setSSLVerifyHost(false); // http://developer.wikidot.com/doc:api // http://developer.wikidot.com/doc:api-methods // site.pages(arguments array) // http://phpxmlrpc.sourceforge.net/doc-2/ch07.html#id932680 $sMethodName = "site.pages"; $sSiteName = "THE_SITE_NAME"; // (for instance: http://foobar.wikidot.com should be "foobar" for $sSiteName) $req = new xmlrpcmsg($sMethodName); $req->addParam(new xmlrpcval( array("site" => new xmlrpcval($sSiteName, "string")),"struct")); $res = $oClient->send($req, 30, "https"); $value = $res->value(); if(!$res->faultCode()) { // SUCCESS! echo "success! "; // $value } else { echo "<font color=\"red\"> <H1>Fault</H1><BR>\n". " Code: " . $res->faultCode() . "\n<BR>". " Reason: " . $res->faultString() . "'\n<BR></font>"; } // Fault // Code: 2 // Reason: Invalid return payload: enable debugging to examine incoming payload found not-xmlrpc xml element NIL' ==> BECAUSE OF NIL NOT RECOGNIZED in the php xml rpc library! Fixing is explained below. // Fix in file xmlrpc.inc: // At line 2539, add: // FIX!!! http://www.devraju.com/2010/07/magento-xml-rpc-api-invalid-return-payload-enable-debugging-to-examine-incoming-payload-found-not-xmlrpc-xml-element-nil-for-product-info/ // $data = str_replace(array('<nil/>','<NIL/>'),'', $data); // \FIX!!! http://www.devraju.com/2010/07/magento-xml-rpc-api-invalid-return-payload-enable-debugging-to-examine-incoming-payload-found-not-xmlrpc-xml-element-nil-for-product-info/
Enjoy!
Karl3i