Created
October 19, 2014 20:59
-
-
Save brasofilo/918bb4e2a63b776bec8e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How a
sayHello
request can be made without username and password