]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Also show XML representation of attachments in the API
authorZach Copley <zach@controlyourself.ca>
Fri, 17 Jul 2009 19:33:51 +0000 (12:33 -0700)
committerZach Copley <zach@controlyourself.ca>
Fri, 17 Jul 2009 19:42:05 +0000 (12:42 -0700)
lib/twitterapi.php

index 749083c7c560399ffee07034bac1942f99ed15bf..66664334c85930207e4412ee720c8c124aff1c92 100644 (file)
@@ -369,6 +369,9 @@ class TwitterapiAction extends Action
             case 'text':
                 $this->element($element, null, common_xml_safe_str($value));
                 break;
+            case 'attachments':
+                $this->show_xml_attachments($twitter_status['attachments']);
+                break;
             default:
                 $this->element($element, null, $value);
             }
@@ -389,6 +392,20 @@ class TwitterapiAction extends Action
         $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)
     {
         $this->elementStart('item');