diff --git a/actions/qvitter.php b/actions/qvitter.php index b7edba9..b01cec8 100644 --- a/actions/qvitter.php +++ b/actions/qvitter.php @@ -174,24 +174,66 @@ class QvitterAction extends ApiAction } } - // oembed discovery for local notices + // oembed discovery for local notices, and twitter cards if(substr($_SERVER['REQUEST_URI'],0,8) == '/notice/' && $this->arg('notice') && array_key_exists('Oembed', StatusNet::getActivePlugins())) { $notice = Notice::getKV('id', $this->arg('notice')); + if($notice instanceof Notice) { - if ($notice->isLocal()) { + $profile = $notice->getProfile(); + if ($notice->isLocal() && $profile instanceof Profile) { + + // maybe get thumbnail url + $embed_thumbnail_url = false; + $attachments = $notice->attachments(); + if (!empty($attachments)) { + foreach ($attachments as $attachment) { + if(is_object($attachment)) { + try { + $thumb = $attachment->getThumbnail(); + } catch (ServerException $e) { + // + } + if(!empty($thumb) && method_exists('File_thumbnail','url')) { + try { + $embed_thumbnail_url = File_thumbnail::url($thumb->filename); + break; // only first one + } catch (ClientException $e) { + // + } + } + } + } + } + try { $notice_url = $notice->getUrl(); - print ''; - print ''; + print ''."\n"; + print ''."\n"; } catch (Exception $e) { // } + + // twitter cards + print ''."\n"; + print ''."\n"; + print ''."\n"; + if($embed_thumbnail_url) { + print ''."\n"; + } + + // opengraph + print ''."\n"; + print ''."\n"; + if($embed_thumbnail_url) { + print ''."\n"; + } } } } + ?>