Also show XML representation of attachments in the API

This commit is contained in:
Zach Copley 2009-07-17 12:33:51 -07:00
parent 0cfdc2b91b
commit 348fa35c6b

View File

@ -369,6 +369,9 @@ class TwitterapiAction extends Action
case 'text': case 'text':
$this->element($element, null, common_xml_safe_str($value)); $this->element($element, null, common_xml_safe_str($value));
break; break;
case 'attachments':
$this->show_xml_attachments($twitter_status['attachments']);
break;
default: default:
$this->element($element, null, $value); $this->element($element, null, $value);
} }
@ -389,6 +392,20 @@ class TwitterapiAction extends Action
$this->elementEnd($role); $this->elementEnd($role);
} }
function show_xml_attachments($attachments) {
if (!empty($attachments)) {
$this->elementStart('attachments', array('type' => 'array'));
foreach ($attachments as $attachment) {
$attrs = array();
$attrs['url'] = $attachment['url'];
$attrs['mimetype'] = $attachment['mimetype'];
$attrs['size'] = $attachment['size'];
$this->element('enclosure', $attrs, '');
}
$this->elementEnd('attachments');
}
}
function show_twitter_rss_item($entry) function show_twitter_rss_item($entry)
{ {
$this->elementStart('item'); $this->elementStart('item');