Skip to content

Instantly share code, notes, and snippets.

@brasofilo
Created October 19, 2014 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brasofilo/918bb4e2a63b776bec8e to your computer and use it in GitHub Desktop.
Save brasofilo/918bb4e2a63b776bec8e to your computer and use it in GitHub Desktop.
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();
@anuj9196
Copy link

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