Как получить название / описание видео Vine?
Вот пример видео из лозы https://vine.co/v/bjHh0zHdgZT. Как я могу получить только его описание?
Допустим, у меня есть идентификатор видео, который является bjHh0zHdgZT, и мне нужно получить описание вин для моего сайта на основе PHP.
Благодарю.
1 ответ
Решение
Может быть, вы можете разобрать метатег страницы?
Источник страницы лозы:
<meta property="twitter:card" content="player">
<meta property="twitter:title" content="Jethro Ames's post on Vine">
<meta property="twitter:description" content="SquareVine 1 #howto #favthings #loop">
Чтобы получить описание от php с file_get_contents и preg_match:
<?php
$url = "https://vine.co/v/bjHh0zHdgZT";
$data = file_get_contents($url);
preg_match('~<\s*meta\s+property="(twitter:description)"\s+content="([^"]*)~i', $data, $matches);
print_r($matches);
if ( isset($matches[2]) ) {
$description = $matches[2];
}
?>
Выход:
Array
(
[0] => <meta property="twitter:description" content="SquareVine 1 #howto #favthings #loop
[1] => twitter:description
[2] => SquareVine 1 #howto #favthings #loop
)
Ваше описание: $ соответствует [2]. Будьте внимательны, чтобы контролировать этот контент (html-сущности, sql escape и т. Д.)