Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I embed a video in a tweet?

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?

like image 540
Bankzilla Avatar asked Mar 16 '12 02:03

Bankzilla


People also ask

How do you make a video play in a Tweet?

Click the compose tweet button. Write an engaging caption to go along with your video. Click add media, choose your video file, and click add. Note: Maximum file size is 512MB.

Can you embed in a Tweet?

Click the icon located within the Tweet. From the menu, select Embed Tweet. This will open publish.twitter.com where you can customize the look of the embedded Tweet by clicking set customization options. If the Tweet is a reply to another Tweet, you can check Hide Conversation to hide the original Tweet.

Why can't I add a video to my Tweet?

If the video file doesn't meet Twitter video posting requirements, for example, the video is too long, the file size is too large, or the video format is not supported, you will end up with failure in posting a video to Twitter. According to Twitter's official policy, the video length could be between 0.5s to 140s.


2 Answers

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.

like image 158
Alexander Avatar answered Oct 01 '22 02:10

Alexander


Use http://tinyurl.com/ and put in the url of your YouTube video it will give you a smaller url and tweet that

like image 40
Micah Armantrout Avatar answered Oct 01 '22 02:10

Micah Armantrout