XML-RPC for PHP Connection Error Solution
I’m posting this for my own benefit so that I can remember in the future, as well as for your benefit if you’re experiencing the same problem.
When using XML-RPC for PHP, you get a very weird error back on some hosting platforms when you’ve given the XML-RPC interface an invalid domain.
With the XML-RPC debug level set to 3, here’s what I’ve been getting back in return.
---SENDING--- POST /xmlrpc.php HTTP/1.0 User-Agent: XML-RPC for PHP 2.2 Host: http://www.example.com:80 Accept-Encoding: gzip, deflate Accept-Charset: UTF-8,ISO-8859-1,US-ASCII Content-Type: text/xml Content-Length: 276 <?xml version="1.0"?> <methodCall> <methodName>metaWeblog.getCategories</methodName> <params> <param> <value><string>1</string></value> </param> <param> <value><string>userid</string></value> </param> <param> <value><string>password</string></value> </param> </params> </methodCall> ---END--- xmlrpcresp Object ( [val] => 0 [valtyp] => [errno] => 5 [errstr] => Connect error: Success (0) [payload] => [hdrs] => Array ( ) [_cookies] => Array ( ) [content_type] => text/xml [raw_data] => )
Notice the “Connect error: Success(0)? That tells you absolutely nothing.
If you’re experiencing that error, there are two possible reasons for it.
Scenario One: The domain (http://www.domain.com:80) is invalid, and the XML-RPC interface can’t connect to it.
Scenario Two: One of the parameters you pass to the XML-RPC interface is the host. This parameter must not include the “http://” part. If you include that with the parameter you’re passing to the XML-RPC interface, the above is the error it generates. It’s very tough to figure out, because, as you’ll see in the debug output, it looks as if your parameters were processed just fine.
An easy way to extract just the domain from an URL in PHP is as follows:
<?php $url = 'http://www.domain.com'; $url_array = parse_url($url); $domain = $url_array['host']; echo $domain; ?>
The above code will output “www.domain.com”.














