能够在2分钟内发布YouTube视频

Is there any way for a website to let users embed ONLY short youtube videos. Let's say 2min or shorter.

So when they try to embed the youtube video and if it's over 2 minutes they get an error that tells them "Your video is too long, please choose another" etc...

Is this possible?

Just to be clear, I'm not looking to edit the youtube video length, just prohibit users from posting of videos that are too long.

Thank you very much.

Here's to help you get started:

The base api URL is http://gdata.youtube.com/feeds/api/videos/VIDEO_ID?v=2&alt=json.

<?php

$video_data = json_decode(file_get_contents("http://gdata.youtube.com/feeds/api/videos/a_kAUiJwRs0?v=2&alt=json"),true);

echo $video_data['entry']['title']['$t']." is ".$video_data['entry']['media$group']['yt$duration']['seconds']." seconds long.";

Output:

Love, Fate, Love - Final Approach ED Single Love, Fate, Love Original Soundtrack is 283 seconds long.

Replace a_kAUiJwRs0 with your video ID. You may print_r on $video_data to see all the values you get.

Once you have their video ID, you may check if their duration (in seconds) is longer or shorter than 120 seconds, and reject or accept based on that.

I would recommending reading this to see what video responses will have. (You can always var_dump to see exactly what it returns)

You can get the XML data from:

http://gdata.youtube.com/feeds/api/videos/{$videoId}

which includes the duration. Just check if that is over 120 seconds long