Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
class XMLRPClientWordPress
{
var $XMLRPCURL = "http://www.mysite.com/xmlrpc.php";
var $UserName = "username";
var $PassWord = "password";
// Constructor
public function __construct($xmlrpcurl, $username, $password)
{
$this->XMLRPCURL = $xmlrpcurl;
$this->UserName = $username;
$this->PassWord = $password;
}
// send request function
function send_request($requestname, $params)
{
$request = xmlrpc_encode_request($requestname, $params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_URL, $this->XMLRPCURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
$results = curl_exec($ch);
curl_close($ch);
return $results;
}
// say hello check
function sayHello()
{
$params = array();
return $this->send_request('demo.sayHello',$params);
}
}
$objXMLRPClientWordPress = new XMLRPClientWordPress ("http://example.com/xmlrpc.php" , "username" , "password");
echo $objXMLRPClientWordPress->sayHello();

How a sayHello request can be made without username and password

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment