Using xmlRPC calls in my Wordpress Plugin PHP + Avoid Curl / use HTTP API? Using xmlRPC calls in my Wordpress Plugin PHP + Avoid Curl / use HTTP API? curl curl

Using xmlRPC calls in my Wordpress Plugin PHP + Avoid Curl / use HTTP API?


WordPress includes a XML-RPC class (IXR), it's a matter of

include 'wp-includes/class-IXR.php'; // better with:  ABSPATH . WPINC . '/class-IXR.php';$client = new IXR_Client( 'http://example.com/xmlrpc.php' );if( !$client->query( 'demo.sayHello', array() ) )    echo $client->getErrorMessage();else    echo $client->getResponse();

And for authenticated requests:

$query_args = array(      'post_status' => 'publish',    'post_type'   => 'post',    'number'      => 3);$args = array(    '', // blog_id    'username',    'password',    $query_args);        $result = $client->query( 'wp.getPosts', $args );