如何从谷歌驱动器获取流链接

时间:2016-04-10 03:48:34

标签: javascript php google-drive-api

我想从谷歌驱动器获取流链接而不在网络浏览器上播放。像这样的格式链接。 https://r6---sn-npo7zn7k.c.docs.google.com/videoplayback ..

这是驱动链接演示: https://drive.google.com/file/d/0B8_ZB_L8pVIkejU1ai1GNmhKa0k/view

enter image description here

2 个答案:

答案 0 :(得分:0)

您可以使用Drive REST API

在快速入门教程中,它将介绍如何在JavaScript中使用Drive Rest API,以及如何打开Drive API,为OAuth创建客户端ID等基本操作。

以下是您将在快速入门中看到的示例代码的一部分:

<html>
<head>
<script type="text/javascript">
// Your Client ID can be retrieved from your project in the Google
// Developer Console, https://console.developers.google.com
var CLIENT_ID = '<YOUR_CLIENT_ID>';

var SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly'];

/**
* Check if current user has authorized this application.
*/
function checkAuth() {
gapi.auth.authorize(
{
'client_id': CLIENT_ID,
'scope': SCOPES.join(' '),
'immediate': true
}, handleAuthResult);
}

然后,您将提取webViewLink

的值
  

webViewLink

     
      
  • 仅在公共文件夹上提供的链接,用于通过Google云端硬盘的网站托管查看其静态网络资源(HTML,CSS,JS等)。
  •   

以下是response示例:

{
"kind": "drive#file",
"id": string,
"etag": etag,
"selfLink": string,
"webContentLink": string,
"webViewLink": string,
"alternateLink": string,
"embedLink": string,
"openWithLinks": {
(key): string
},

我希望这会有所帮助。

答案 1 :(得分:0)

您可以使用GetLinkDrive中的API:

例如:http://api.getlinkdrive.com/getlink?url=https://drive.google.com/file/d/0B6VYU2mjTdy0WVRjb1BJUU1hYXM/view

API将响应流链接,如下所示:

[{"label":720,"type":"video/mp4","src":"https://redirector.googlevideo.com/videoplayback?requiressl=yes&id=19e3c7fd6fd45f15&itag=22&source=webdrive&ttl=transient&app=api.getlinkdrive.com&ip=139.162.5.123&ipbits=0&expire=1481719234&sparams=requiressl,id,itag,source,ttl,ip,ipbits,expire&signature=97E76D059F08E8B3B3C37FDE840C6B3978ACDD0C.8AF257B52254C7F116E658D6C52A3C5C3244EF75&key=ck2&mm=31&mn=sn-npoe7n7s&ms=au&mt=1481704609&mv=m&nh=IgpwcjA0LnNpbjExKgkxMjcuMC4wLjE&pl=22&safm=0&filename=video.mp4","file":"https://redirector.googlevideo.com/videoplayback?requiressl=yes&id=19e3c7fd6fd45f15&itag=22&source=webdrive&ttl=transient&app=api.getlinkdrive.com&ip=139.162.5.123&ipbits=0&expire=1481719234&sparams=requiressl,id,itag,source,ttl,ip,ipbits,expire&signature=97E76D059F08E8B3B3C37FDE840C6B3978ACDD0C.8AF257B52254C7F116E658D6C52A3C5C3244EF75&key=ck2&mm=31&mn=sn-npoe7n7s&ms=au&mt=1481704609&mv=m&nh=IgpwcjA0LnNpbjExKgkxMjcuMC4wLjE&pl=22&safm=0&filename=video.mp4","res":720}]