0

I want to use the pingback.extensions.getPingbacks Method with parameters in the url, like post_type or page. I use the code below, but it doesn't work when I want to add a parameter and I get a fault code of 0 and an empty fault string, but it seems to work when I only pass the url without any parameters. Can anyone help me?

<?php

require_once 'class-IXR.php';
$rpc = new IXR_Client('http://localhost/wordpress/wordpress/xmlrpc.php');



$result = $rpc->query('pingback.extensions.getPingbacks','http://localhost/wordpress/wordpress/2018/01/17/hallo-welt/&post_type=something');

if(!$result) {
echo 'Error [' . $rpc->getErrorCode() . ']: ' . $rpc->getErrorMessage();

}

var_dump($rpc->getResponse());


?>

The error message

Error [0]: array(2) { ["faultCode"]=> int(0) ["faultString"]=> string(0) "" } 
0

Note that WordPress ships with WP_HTTP_IXR_CLIENT that extends the IXR_Client. So replace

require_once ABSPATH . WPINC . '/class-IXR.php';
$rpc = new IXR_Client( 'http://localhost/wordpress/wordpress/xmlrpc.php' );

with:

require_once ABSPATH . WPINC . '/class-IXR.php';
require_once ABSPATH . WPINC . '/class-wp-http-ixr-client.php';
$rpc = new WP_HTTP_IXR_CLIENT( 'http://localhost/wordpress/wordpress/xmlrpc.php' );

Then try replacing:

$result = $rpc->query( 
 'pingback.extensions.getPingbacks',
 'http://localhost/wordpress/wordpress/2018/01/17/hallo-welt/&post_type=something'
);

with

$result = $rpc->query( 
 'pingback.extensions.getPingbacks',
 'http://localhost/wordpress/wordpress/2018/01/17/hallo-welt/?post_type=something'
);

The server method wp_xmlrpc_server::pingback_extensions_getPingbacks() uses the url_to_postid() function to convert the url to a post ID. So make sure your url works there!

PS: These days many WordPress users are looking into the new REST-API instead of the XML-RPC API.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.