Miniaturas Youtube e Vimeo
<?php function getVimeo( $video ) { $hash = unserialize( file_get_contents( "http://vimeo.com/api/v2/video/$video.php" ) ); echo $hash[0]['thumbnail_medium']; } function getYoutube( $video ) { $hash = file_get_contents( "http://youtube.com/get_video_info?video_id=$video" ); parse_str( $hash, $arr ); echo $arr['thumbnail_url']; } ?>
<h1>Youtube</h1> <img alt="" src="<?=getYoutube('Vg6LtMlHY_A')?>" /> <h1>Vimeo</h1> <img alt="" src="<?=getVimeo('251266')?>" />
Os códigos passados devem ser retirados dos links, no caso, o texto em vermelho
nos links abaixo:
Rafael, vc saberia como pegar o título e descrição do youtube e vimeo?
Fala Falcão, seguem as funções:
function getThumbYoutube( $video )
{
$hash = file_get_contents( “http://youtube.com/get_video_info?video_id=$video” );
parse_str( $hash, $arr );
return utf8_decode( $arr[‘thumbnail_url’] );
}
function getTitleYoutube( $video )
{
$hash = file_get_contents( “http://youtube.com/get_video_info?video_id=$video” );
parse_str( $hash, $arr );
return utf8_decode( $arr[‘title’] );
}
function getThumbVimeo( $video )
{
$hash = unserialize( file_get_contents( “http://vimeo.com/api/v2/video/$video.php” ) );
return $hash[0][‘thumbnail_medium’];
}
function getTitleVimeo( $video )
{
$hash = unserialize( file_get_contents( “http://vimeo.com/api/v2/video/$video.php” ) );
return $hash[0][‘video_title’];
}
echo getTitleYoutube(“Vg6LtMlHY_A”);
echo getTitleVimeo(“251266”);
Rafael, como eu faço pra pegar de os video que ta cadastrado em um banco de dados?
Tiago, daí seria legal eu saber como está cadastrado no banco… você precisa dar mais detalhes.
Boa tarde Rafael, está me retornando os seguintes erros…
===================================================
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /home/jammal/public_html/fb/joao/videos/index.php on line 78
Warning: file_get_contents(http://youtube.com/get_video_info?video_id=Lhn2wPkA8Xg) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /home/jammal/public_html/fb/joao/videos/index.php on line 78
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /home/jammal/public_html/fb/joao/videos/index.php on line 72
Warning: file_get_contents(http://vimeo.com/api/v2/video/46174971.php) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /home/jammal/public_html/fb/joao/videos/index.php on line 72
===================================================
Tem alguma sugestão?
Crie um arquivo php.ini com o conteúdo:
allow_url_fopen=on
Coloque o arquivo na raiz da aplicação
espantado com sua velocidade de respota.. kkk
amigo.. funcionou apenas com o vimeo, o youtube parou de dar erro, mas tbm nao aparece nada ..
Dá uma conferida no código porque eu testei e está ok, veja:
http://imageshack.us/photo/my-images/198/thumbsw.png/
http://pastebin.com/UZ3xhn1Y
Boa tarde Rafael, o script para pegar o titulo não está funcionando com o Vimeo.
function getTitleVimeo( $video )
{
$hash = unserialize( file_get_contents( “http://vimeo.com/api/v2/video/$video.php” ) );
return $hash[0][‘video_title’];
}
e não da nenhuma msn de erro,
do youtube está funcionado perfeitamente.
grato por ajudar
Luiz, estou vendo que na minha demo funciona normalmente.
Olha, crie (ou adicione ao seu) um php.ini com a seguinte linha:
allow_url_fopen=on
Isso irá habilitar o file_get_contents;
Rafael Clares vc poderia me ajudar? eu queria saber como colocara miniatura dos videos da uol
Youto, desculpe mas não tenho ideia, na verdade, nem sabia que tinha vídeos lá.