XML-RPC and cURLS
-
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:<backticks>
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/></value></param>”.
“<param><value><string/></value></param>”.
“<param><value><string>”.$username.”</string></value></param>”.
“<param><value><string>”.$password.”</string></value></param>”.
“<param><value><string><title> TITOLO </title><category> CATEGORIA </category> BODY </string></value></param>”.
“<param><value><int>1</int></value></param>”.
“</params></methodCall>”;curl_setopt($ch,CURLOPT_POSTFIELDS,$curlStr);
curl_setopt($ch, CURLOPT_URL, $rpcurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
$results = curl_exec($ch);
return $results;
}</backticks>
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,
Ale
- The topic ‘XML-RPC and cURLS’ is closed to new replies.