如何将视频嵌入推文中? [英] How do I embed a video in a tweet?

查看:1160
本文介绍了如何将视频嵌入推文中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近应客户要求注册了Twitter。在Twitter上发布我的视频的URL或直接链接到.mp4时,我只是得到该链接。



与youtube尝试相同时,会有一个下拉菜单查看视频标签。
是否需要发送特定的标头?我在API或Google中找不到它。或对此有任何疑问!



还是该站点需要由Twitter自己列入白名单?

解决方案

这个问题还很老,但是它有很多观点,没有一个是正确的解决方案。



Twitter有名为 Twitter卡的功能,该功能可让您将网站上的视频直接嵌入鸣叫。若要实现此目的,您将需要通过元数据将播放器卡添加到您的网站。



实施Twitter Card只需向您的代码添加几行代码HTML头。您可以在此处找到一些示例。为了方便起见,我将粘贴一个示例:

 <!DOCTYPE html> 
< html>
< head>
..

<元名称= twitter:card content = player>
<元名称= twitter:站点 content = @ rchoi>
<元名称= twitter:title content =样本播放器卡>
< meta name = twitter:description content =这是一个示例视频。实施时,请确保所有链接都是安全的。
< meta name = twitter:image content = https://yoursite.com/example.png>
<元名称= twitter:player content = https://yoursite.com/container.html>
<元名称= twitter:player:width content = 480>
<元名称= twitter:player:height content = 480>
<元名称= twitter:player:stream content = https://yoursite.com/example.mp4>
<元名称= twitter:player:stream:content_type content = video / mp4>

..
< / head>

..

< / html>

并非所有 meta 属性都是必需的。您可以在Twitter的开发人员网站上找到它们的列表:玩家卡参考。 / p>

您还需要将您的Twitter帐户列入Twitter卡的白名单。您可以在卡片验证器中进行操作。预览卡后,将出现一个按钮,您可以选择请求访问Twitter卡。


I recently signed up for Twitter at a client's request. When posting my video's URL or direct link to the .mp4 on Twitter, I'm just getting the link.

When attempting the same with youtube, there is a dropdown "view video" tab. Is there specific headers that are needing to be sent? I can't find it in the API or on Google. Or any question asked on here about it!

Or is the site needing to be whitelisted by Twitter themselves?

解决方案

This question is rather old, but it has quite a few views, and none of the solutions are correct.

Twitter has a feature called Twitter Cards that will allow you to have the videos on your website embedded directly in tweets. You will need to add a Player Card to your website via meta data if you would like to achieve this.

Implementing Twitter Cards only requires adding a few lines of code to your HTML head. You can find some examples here. I'll paste one example for your convenience:

<!DOCTYPE html>
<html>
    <head>
        ..

        <meta name="twitter:card" content="player">
        <meta name="twitter:site" content="@rchoi">
        <meta name="twitter:title" content="Sample Player Card">
        <meta name="twitter:description" content="This is a sample video. When you implement, make sure all links are secure.">
        <meta name="twitter:image" content="https://yoursite.com/example.png">
        <meta name="twitter:player" content="https://yoursite.com/container.html">
        <meta name="twitter:player:width" content="480">
        <meta name="twitter:player:height" content="480">
        <meta name="twitter:player:stream" content="https://yoursite.com/example.mp4">
        <meta name="twitter:player:stream:content_type" content="video/mp4">

        ..
    </head>

    ..

</html>

Not all of the meta properties are required. You can find a list of them on Twitter's developer website: Player Card Reference.

You will also need to get your Twitter account whitelisted for Twitter Cards. You can do so at the Card validator. Once you preview your card, a button should appear, giving you the option to request access to Twitter Cards.

这篇关于如何将视频嵌入推文中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆