legion of one

The personal blog of Dewald Pretorius

Subscribe to legion of one

Archive for the ‘Geek’ Category

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”.

I love Twitter’s approach of providing the basic functionality and allowing third-party developers to create value-add applications through the use of the Twitter API.

One thing that’s sorely lacking, is the ability to follow conversation threads in Twitter. Some folks have tried to create applications to do that, but it’s hit and miss, because tweet matching must currently occur either on keywords, or time proximity, or both.

Twitter can open a new world of Twitter conversation threading by doing the following:

Step One — On each reply, record and store the tweet number of the original entry that’s being replied to.

When someone clicks the reply icon, record the original tweet number:

Step Two — Make the replied-to tweet number available on the record of a tweet in the API, as well as a list of tweet numbers that are replies to this tweet.

Step Three — Provide an API call to retrieve the details of a specific tweet.

These three simple steps will enable third-party developers to create awesome applications to show how threaded conversions occur and evolve within Twitter.