Hello, everyone.
I developed a small plugin for a client who’s still on PHP 7.0 and the IT person is being difficult about upgrading to PHP 7.4 want to upgrade.
I have a small Vimeo script that reads out a supplied URL and then returns the parameters (video title, link and thumbnail). It’s not working on the live site, here is my snippet:
<?php
// get fields
$video_url = get_field('vimeo_url'); // example using ACF (works similar)
$url_pieces = explode('/', $video_url);
?>
<?php if( preg_match('/https:\/\/(www\.)*vimeo\.com\/.*/', $video_url) ) { ?>
<?php
// vimeo
$id = $url_pieces[3];
$hash = unserialize( file_get_contents('http://vimeo.com/api/v2/video/' . $id . '.php') );
// this is for testing --- included dump below
echo '<pre>';
var_dump($hash);
echo '</pre>';
$thumbnail = $hash[0]['thumbnail_large'];
?>
<div class="col-sm-3">
<a class="videos-list--item popup-vimeo" href="<?php echo $video_url ?>" style="background-image:url('<?php echo $thumbnail; ?>');" data-lity >
<p class="video-title"><?php the_title(); ?></p>
</a>
</div>
<?php } ?>
And then this is an example of the var dump output generated by the var_dump in the snippet above:
array(1) {
[0]=>
array(23) {
["id"]=>
int(297401184)
["title"]=>
string(13) "Face and Body"
["description"]=>
string(0) ""
["url"]=>
string(27) "https://vimeo.com/297401184"
["upload_date"]=>
string(19) "2018-10-26 17:27:48"
["thumbnail_small"]=>
string(48) "http://i.vimeocdn.com/video/735070657_100x75.jpg"
["thumbnail_medium"]=>
string(49) "http://i.vimeocdn.com/video/735070657_200x150.jpg"
["thumbnail_large"]=>
string(45) "http://i.vimeocdn.com/video/735070657_640.jpg"
["user_id"]=>
int(47140717)
["user_name"]=>
string(27) "Motion Analysis Corporation"
["user_url"]=>
string(32) "https://vimeo.com/motionanalysis"
["user_portrait_small"]=>
string(45) "http://i.vimeocdn.com/portrait/32378470_30x30"
["user_portrait_medium"]=>
string(45) "http://i.vimeocdn.com/portrait/32378470_75x75"
["user_portrait_large"]=>
string(47) "http://i.vimeocdn.com/portrait/32378470_100x100"
["user_portrait_huge"]=>
string(47) "http://i.vimeocdn.com/portrait/32378470_300x300"
["stats_number_of_likes"]=>
int(0)
["stats_number_of_plays"]=>
int(26)
["stats_number_of_comments"]=>
int(0)
["duration"]=>
int(45)
["width"]=>
int(1280)
["height"]=>
int(720)
["tags"]=>
string(9) "Animation"
["embed_privacy"]=>
string(8) "anywhere"
}
}