Home » Php » php – How to get Vine video url

php – How to get Vine video url

Posted by: admin July 12, 2020 Leave a comment

Questions:

I love vinepeek and want to make something better.

I have the Vine link e.g. http://vine.co/v/bJqWrOHjMmU, however this is a link to a page, not the video URL.

I know it’s new, but does Vine have an API, or how else would I be able to get the url of the video? I’m still puzzled as to how Vinepeek gets the video url?

How to&Answers:

It is in the page source; you could parse it with a JavaScript bookmarklet

function qry(sr) {
  var qa = [];
  for (var prs of sr.split('&')) {
    var pra = prs.split('=');
    qa[pra[0]] = pra[1];
  }
  return qa;
}

var alpha = document.querySelector('[name=flashvars]').getAttribute('value');
var bravo = qry(alpha);
bravo.src;

Result

https://vines.s3.amazonaws.com/videos/08C49094-DFB4-46DF-8110-EEEC7D4D6115-1133-000000B8AD9BE72C_1.0.1.mp4?versionId=TQGtC5O7G7H34TleFA2LF0Er9tI8VZUe

Source

Answer:

The JSON API has the following URL: http://vinepeek.com/video

You can use a web inspector / console / developer tool to check the source code.

<video id="post_html5_api" class="vjs-tech" loop="" preload="auto" src="https://vines.s3.amazonaws.com/videos/08C49094-DFB4-46DF-8110-EEEC7D4D6115-1133-000000B8AD9BE72C_1.0.1.mp4?versionId=TQGtC5O7G7H34TleFA2LF0Er9tI8VZUe"></video>

The URL is:

https://vines.s3.amazonaws.com/videos/08C49094-DFB4-46DF-8110-EEEC7D4D6115-1133-000000B8AD9BE72C_1.0.1.mp4?versionId=TQGtC5O7G7H34TleFA2LF0Er9tI8VZUe

Answer:

This is a simple function which i use to get video src from curl result.
http://vine.co/v/bJqWrOHjMmU

function getVineVideoFromUrl($url) {
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $res = curl_exec($ch);
    preg_match('/twitter:player:stream.*content="(.*)"/', $res, $output);
    return $output[1];
}

result

https://vines.s3.amazonaws.com/v/videos/08C49094-DFB4-46DF-8110-EEEC7D4D6115-1133-000000B8AD9BE72C_1.0.1.mp4?versionId=ms6ePoPeFm6NQZkeNHegV3k_ZLV4bz9x