diff options
author | Zach Copley <zach@controlyourself.ca> | 2009-07-17 14:22:11 -0700 |
---|---|---|
committer | Zach Copley <zach@controlyourself.ca> | 2009-07-17 14:25:36 -0700 |
commit | 44f3f2bd2af07b6fb5eb8f2516e137e89db7d4a4 (patch) | |
tree | d9133c8242d6850461cefb6d87b398a00a447917 | |
parent | 9c670ba695d14068d1d159a91d0699f2677dad91 (diff) |
Only create attachment elements if attachment is an enclosure
-rw-r--r-- | lib/twitterapi.php | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/lib/twitterapi.php b/lib/twitterapi.php index ab6c0d62c..79da82a19 100644 --- a/lib/twitterapi.php +++ b/lib/twitterapi.php @@ -186,24 +186,24 @@ class TwitterapiAction extends Action $twitter_status['favorited'] = false; } - # Enclosures + // Enclosures $attachments = $notice->attachments(); - - if (!empty($attachments)) { - - $twitter_status['attachments'] = array(); - - foreach ($attachments as $attachment) { - if ($attachment->isEnclosure()) { - $enclosure = array(); - $enclosure['url'] = $attachment->url; - $enclosure['mimetype'] = $attachment->mimetype; - $enclosure['size'] = $attachment->size; - $twitter_status['attachments'][] = $enclosure; - } + $enclosures = array(); + + foreach ($attachments as $attachment) { + if ($attachment->isEnclosure()) { + $enclosure = array(); + $enclosure['url'] = $attachment->url; + $enclosure['mimetype'] = $attachment->mimetype; + $enclosure['size'] = $attachment->size; + $enclosures[] = $enclosure; } } + if (!empty($enclosures)) { + $twitter_status['attachments'] = $enclosures; + } + if ($include_user) { # Don't get notice (recursive!) $twitter_user = $this->twitter_user_array($profile, false); @@ -218,7 +218,7 @@ class TwitterapiAction extends Action $profile = $notice->getProfile(); $entry = array(); - # We trim() to avoid extraneous whitespace in the output + // We trim() to avoid extraneous whitespace in the output $entry['content'] = common_xml_safe_str(trim($notice->rendered)); $entry['title'] = $profile->nickname . ': ' . common_xml_safe_str(trim($notice->content)); @@ -231,7 +231,26 @@ class TwitterapiAction extends Action $entry['updated'] = $entry['published']; $entry['author'] = $profile->getBestName(); - # Enclosure + // Enclosures + $attachments = $notice->attachments(); + $enclosures = array(); + + foreach ($attachments as $attachment) { + if ($attachment->isEnclosure()) { + $enclosure = array(); + $enclosure['url'] = $attachment->url; + $enclosure['mimetype'] = $attachment->mimetype; + $enclosure['size'] = $attachment->size; + $enclosures[] = $enclosure; + } + } + + if (!empty($enclosures)) { + $entry['enclosures'] = $enclosures; + } + +/* + // Enclosure $attachments = $notice->attachments(); if($attachments){ $entry['enclosures']=array(); @@ -245,8 +264,8 @@ class TwitterapiAction extends Action } } } - - # RSS Item specific +*/ + // RSS Item specific $entry['description'] = $entry['content']; $entry['pubDate'] = common_date_rfc2822($notice->created); $entry['guid'] = $entry['link']; |