Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何获取视频标题/描述?_Php_Api_Video_Twitter_Vine - Fatal编程技术网

Php 如何获取视频标题/描述?

Php 如何获取视频标题/描述?,php,api,video,twitter,vine,Php,Api,Video,Twitter,Vine,下面是一个视频示例。我怎样才能得到它的描述 假设我有视频的id,它是bjHh0zHdgZT,我需要得到vine对我基于PHP的网站的描述 谢谢。也许你可以解析页面的元标记 vine页面的来源: <meta property="twitter:card" content="player"> <meta property="twitter:title" content="Jethro Ames's post on Vine"> <meta property="twitt

下面是一个视频示例。我怎样才能得到它的描述

假设我有视频的id,它是bjHh0zHdgZT,我需要得到vine对我基于PHP的网站的描述


谢谢。

也许你可以解析页面的元标记

vine页面的来源:

<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">

要使用文件内容和preg\u匹配从php获取描述:

<?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
)
数组
(
[0] =>