XMLRPC won’t connect?

Instead of using XMLRPC which isn’t available on some hosts, use the REST API instead.

Send a HTTP POST request to the posts endpoint containing a JSON object with your desired post, with an authentication header.

To do this, we’re going to need an authentication plugin ( standard WP only supports nonce + cookie which isn’t useful for an external app ).

First, install the JSON Basic auth plugin https://github.com/WP-API/Basic-Auth

With this we can now do this on a remote WP site to create posts:

$response = wp_remote_post(
    'https://example.com/wp-json/wp/v2/posts',
    [
        'headers' => [
            'Authorization' => 'Basic ' . base64_encode( 'username:password' )
        ],
        'body' => [
            'title'   => 'Post Title',
            'status'  => 'publish',
            'content' => 'Hello World!',
        ],
    ]
);

if ( wp_remote_retrieve_response_message( $response ) === 'Created' ) {
    echo 'success!';
}

Likewise we can use other tools, e.g. here is the same example written as a curl command for the command line:

curl --user admin:password -X POST -H "Content-Type: application/json" -d "{title:'Post Title',status:'publish',content:'hello world'}" https://example.com/wp-json/wp/v2/posts