php php - 获取vimeo视频缩略图图片网址

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php php - 获取vimeo视频缩略图图片网址相关的知识,希望对你有一定的参考价值。


<?php

    /**
     * Gets the thumbnail url for a vimeo video using the video id. This only works for public videos.
     *
     * @param string $id        The video id.
     * @param string $thumbType Thumbnail image size. supported sizes: small, medium (default) and large.
     *
     * @return string|bool
     */

    function getVimeoVideoThumbnailByVideoId( $id = '', $thumbType = 'medium' ) {

        $id = trim( $id );

        if ( $id == '' ) {
            return FALSE;
        }

        $apiData = unserialize( file_get_contents( "http://vimeo.com/api/v2/video/$id.php" ) );

        if ( is_array( $apiData ) && count( $apiData ) > 0 ) {

            $videoInfo = $apiData[ 0 ];

            switch ( $thumbType ) {
                case 'small':
                    return $videoInfo[ 'thumbnail_small' ];
                    break;
                case 'large':
                    return $videoInfo[ 'thumbnail_large' ];
                    break;
                case 'medium':
                    return $videoInfo[ 'thumbnail_medium' ];
                default:
                    break;
            }

        }

        return FALSE;

    }

    // Example usage ...

    $videoId = '145154247';

    echo '<img src="'.getVimeoVideoThumbnailByVideoId($videoId,'small').'" title="Small Thumbnail">'.'<br>';
    echo '<img src="'.getVimeoVideoThumbnailByVideoId($videoId,'medium').'" title="Medium Thumbnail">'.'<br>';
    echo '<img src="'.getVimeoVideoThumbnailByVideoId($videoId,'large').'" title="Large Thumbnail">'.'<br>';
    
    

以上是关于php php - 获取vimeo视频缩略图图片网址的主要内容,如果未能解决你的问题,请参考以下文章

php 获取Vimeo视频缩略图

php 获取Vimeo视频缩略图

php 获取Vimeo视频缩略图

php 获取Vimeo视频缩略图

如何使用 php 获取 youtube 和 vimeo 嵌入代码的视频缩略图?

php 抓取私人(但可嵌入)Vimeo视频的缩略图