我正在尝试使用 XMLRPC 删除 wordpress 帖子,我创建了一个函数,但它返回了一个奇怪的东西:
function deletePost($rpcurl,$username,$password,$post_id)
{
// xmlrpc settings
$params = array(0,$username,$password,$post_id);
// run xmlrpc
$request = xmlrpc_encode_request('wp.deletePost', $params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_URL, $rpcurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
$results = curl_exec($ch);
curl_close($ch);
// testing
var_dump( $results);
return $results;
}
这是返回的内容(一旦剥离了一些 xml 标签):
<name>faultCode</name>
<value><int>-32601</int></value>
<name>faultString</name>
<value><string>server error. requested method wp.deletePost does not exist.</string>