Issues

ZF-8615: Twitter geo information not parsed

Description

The geotagging information isn't parsed properly from a tweet with geo information attached. There is a geo array item returned in the result object but it is empty.

I would guess this is due to the geo information belonging to a different namespace, below is a snippet:

www.georss.org/georss"> 54.39790844 -1.85352928

Comments

After looking at this further, it seems this issue may actually be a problem with Zend_Rest_Client_Response and SimpleXML needing namespaces to be registered before xpath will read them.

The following code will at least get the coordinates out:



// Get User Timeline
$twitter = new Zend_Service_Twitter('username','password');
$response = $twitter->status->userTimeline();

// Register Namespaces
$simpleXml = $response->getIterator();
$namespaces = $simpleXml->getNamespaces(true);
foreach ($namespaces as $prefix => $ns) {
    $simpleXml->registerXPathNamespace($prefix, $ns);
}

// Print list of geo tags if they exist
print_r($simpleXml->xpath('//georss:point'));

I haven't got as far as trying to patch Zend_Rest_Client_Response to return namespaced elements, but the above code should at least help with demonstrating the problem and / or help someone with implementing a fix.

^ and when I say Zend_Rest_Client_Response I really mean Zend_Rest_Client_Result