vimeo 镜像

Vimeo API – OAuth and Upload Example Today I would like to continue talking about video. Last time we talked about Youtube, but today I decided to select Vimeo. Maybe you are owner of your own video website, maybe you are thinking about it, but anyway I think that our information will be useful for you. As you know, video usually means that you need to have a lot of space at hard disk of your hosting account. And it is true in case if you store video files at your own server. But, you can avoid all these difficulties (video storing and conversion) – you can try to work with 3-rd party video hostings. Our second example – Vimeo. In our new tutorial I will tell you how you can create Vimeo cross-uploader for your website.

Vimeo API – OAuth和上载示例今天,我想继续谈论视频。 上次我们谈论Youtube,但今天我决定选择Vimeo。 也许您是自己的视频网站的所有者,也许您正在考虑,但无论如何,我认为我们的信息对您有用。 如您所知,视频通常意味着您需要在托管帐户的硬盘上留出大量空间。 如果您将视频文件存储在自己的服务器上,则情况确实如此。 但是,您可以避免所有这些困难(视频存储和转换)–您可以尝试使用第三方视频托管。 我们的第二个示例– Vimeo。 在我们的新教程中,我将告诉您如何为您的网站创建Vimeo交叉上传器。

To achieve our idea we will use Vimeo Upload API. In the beginning, we should register at Vimeo here. After, please open this page. Now, we shoud create our own application (upload application). Please click ‘Create a new app’ button at the right. Here we should fill all the fields. As ‘App URL’ – you should use your result application URL, as ‘App Callback URL’ – you can use the same url (as App URL). As result – we should obtain Vimeo’s Consumer Key and Secret keys. We are going to use them in our project. Don’t forget to send request to Vimeo in order to get access to upload feature. Once you get it – you can continue.

为了实现我们的想法,我们将使用Vimeo Upload API 。 在开始的时候,我们应该在Vimeo的注册这里 。 之后,请打开此页面 。 现在,我们应该创建自己的应用程序(上传应用程序)。 请点击右侧的“创建新应用”按钮。 在这里,我们应该填写所有字段。 作为“应用程序URL”,您应使用结果应用程序URL;作为“应用程序回调URL”,您可以使用相同的URL(作为应用程序URL)。 结果–我们应该获得Vimeo的使用者密钥和秘密密钥。 我们将在项目中使用它们。 不要忘记发送请求到Vimeo以获得对上传功能的访问。 一旦获得它–您就可以继续。

现场演示

[sociallocker]

[社交储物柜]

打包下载

[/sociallocker]

[/ sociallocker]

Now – download the source files and lets start coding !

现在–下载源文件并开始编码!

步骤1. PHP (Step 1. PHP)

Now, please create an empty index.php file and put next code:

现在,请创建一个空的index.php文件并放入下一个代码:

index.php (index.php)


<?php
// prepare our Consumer Key and Secret
$consumer_key = 'CONSUMER_KEY';
$consumer_secret = 'CONSUMER_SECRET';
require_once('vimeo.php');
session_start();
$sUploadResult = '';
switch ($_REQUEST['action']) {case 'clear': // Clear sessionsession_destroy();session_start();break;case 'upload': // Upload video$vimeo = new phpVimeo($consumer_key, $consumer_secret, $_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']);$video_id = $vimeo->upload($_FILES['file']['tmp_name']);if ($video_id) {$sUploadResult = 'Your video has been uploaded and available <a href="http://vimeo.com/'.$video_id.'">here</a> !';$vimeo->call('vimeo.videos.setPrivacy', array('privacy' => 'nobody', 'video_id' => $video_id));$vimeo->call('vimeo.videos.setTitle', array('title' => $_POST['title'], 'video_id' => $video_id));$vimeo->call('vimeo.videos.setDescription', array('description' => $_POST['description'], 'video_id' => $video_id));} else {$sUploadResult = 'Video Fails to Upload, try again later.';}break;default:// Create the object and enable caching$vimeo = new phpVimeo($consumer_key, $consumer_secret);$vimeo->enableCache(phpVimeo::CACHE_FILE, './cache', 300);break;
}
// Setup initial variables
$state = $_SESSION['vimeo_state'];
$request_token = $_SESSION['oauth_request_token'];
$access_token = $_SESSION['oauth_access_token'];
// Coming back
if ($_REQUEST['oauth_token'] != NULL && $_SESSION['vimeo_state'] === 'start') {$_SESSION['vimeo_state'] = $state = 'returned';
}
// If we have an access token, set it
if ($_SESSION['oauth_access_token'] != null) {$vimeo->setToken($_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']);
}
$bUploadCase = false;
switch ($_SESSION['vimeo_state']) {default:// Get a new request token$token = $vimeo->getRequestToken();// Store it in the session$_SESSION['oauth_request_token'] = $token['oauth_token'];$_SESSION['oauth_request_token_secret'] = $token['oauth_token_secret'];$_SESSION['vimeo_state'] = 'start';// Build authorize link$authorize_link = $vimeo->getAuthorizeUrl($token['oauth_token'], 'write');break;case 'returned':// Store itif ($_SESSION['oauth_access_token'] === NULL && $_SESSION['oauth_access_token_secret'] === NULL) {// Exchange for an access token$vimeo->setToken($_SESSION['oauth_request_token'], $_SESSION['oauth_request_token_secret']);$token = $vimeo->getAccessToken($_REQUEST['oauth_verifier']);// Store$_SESSION['oauth_access_token'] = $token['oauth_token'];$_SESSION['oauth_access_token_secret'] = $token['oauth_token_secret'];$_SESSION['vimeo_state'] = 'done';// Set the token$vimeo->setToken($_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']);}// display upload videofile form$bUploadCase = true;break;
}
?>
<!DOCTYPE html>
<html lang="en" ><head><meta charset="utf-8" /><title>Vimeo API - OAuth and Upload Example | Script Tutorials</title><link href="css/main.css" rel="stylesheet" type="text/css" /></head><body><header><h2>Vimeo API - OAuth and Upload Example</h2><a href="https://www.script-tutorials.com/vimeo-api-oauth-and-upload-example/" class="stuts">Back to original tutorial on <span>Script Tutorials</span></a></header><img src="vim.png" class="vim" alt="vimeo" /><?php if ($_SESSION['vimeo_state'] == 'start'): ?><center><h1>Step 1. OAuth</h1><h2>Click the link to go to Vimeo to authorize your account.</h2><p><a href="<?= $authorize_link ?>"><?php echo $authorize_link ?></a></p></center><?php endif ?><?php if ($bUploadCase && $sUploadResult == ''): ?><center><h1>Step 2. Video info</h1><h2>Now we should send video file, title and description to Vimeo</h2></center><form enctype="multipart/form-data" action="index.php" method="post"><input type="hidden" name="action" value="upload" /><label for="file">Please choose a file:</label><input name="file" type="file" /><label for="title">Title:</label><input name="title" type="text" /><label for="description">Description:</label><input name="description" type="text" /><input type="submit" value="Upload" /></form><?php endif ?><?php if ($sUploadResult): ?><center><h1>Step 4. Final</h1><h2><?php echo $sUploadResult ?></h2></center><?php endif ?><br /><center><h2>(<a href="?action=clear">Click here to start over</a>)</h2></center></body>
</html>

<?php
// prepare our Consumer Key and Secret
$consumer_key = 'CONSUMER_KEY';
$consumer_secret = 'CONSUMER_SECRET';
require_once('vimeo.php');
session_start();
$sUploadResult = '';
switch ($_REQUEST['action']) {case 'clear': // Clear sessionsession_destroy();session_start();break;case 'upload': // Upload video$vimeo = new phpVimeo($consumer_key, $consumer_secret, $_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']);$video_id = $vimeo->upload($_FILES['file']['tmp_name']);if ($video_id) {$sUploadResult = 'Your video has been uploaded and available <a href="http://vimeo.com/'.$video_id.'">here</a> !';$vimeo->call('vimeo.videos.setPrivacy', array('privacy' => 'nobody', 'video_id' => $video_id));$vimeo->call('vimeo.videos.setTitle', array('title' => $_POST['title'], 'video_id' => $video_id));$vimeo->call('vimeo.videos.setDescription', array('description' => $_POST['description'], 'video_id' => $video_id));} else {$sUploadResult = 'Video Fails to Upload, try again later.';}break;default:// Create the object and enable caching$vimeo = new phpVimeo($consumer_key, $consumer_secret);$vimeo->enableCache(phpVimeo::CACHE_FILE, './cache', 300);break;
}
// Setup initial variables
$state = $_SESSION['vimeo_state'];
$request_token = $_SESSION['oauth_request_token'];
$access_token = $_SESSION['oauth_access_token'];
// Coming back
if ($_REQUEST['oauth_token'] != NULL && $_SESSION['vimeo_state'] === 'start') {$_SESSION['vimeo_state'] = $state = 'returned';
}
// If we have an access token, set it
if ($_SESSION['oauth_access_token'] != null) {$vimeo->setToken($_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']);
}
$bUploadCase = false;
switch ($_SESSION['vimeo_state']) {default:// Get a new request token$token = $vimeo->getRequestToken();// Store it in the session$_SESSION['oauth_request_token'] = $token['oauth_token'];$_SESSION['oauth_request_token_secret'] = $token['oauth_token_secret'];$_SESSION['vimeo_state'] = 'start';// Build authorize link$authorize_link = $vimeo->getAuthorizeUrl($token['oauth_token'], 'write');break;case 'returned':// Store itif ($_SESSION['oauth_access_token'] === NULL && $_SESSION['oauth_access_token_secret'] === NULL) {// Exchange for an access token$vimeo->setToken($_SESSION['oauth_request_token'], $_SESSION['oauth_request_token_secret']);$token = $vimeo->getAccessToken($_REQUEST['oauth_verifier']);// Store$_SESSION['oauth_access_token'] = $token['oauth_token'];$_SESSION['oauth_access_token_secret'] = $token['oauth_token_secret'];$_SESSION['vimeo_state'] = 'done';// Set the token$vimeo->setToken($_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']);}// display upload videofile form$bUploadCase = true;break;
}
?>
<!DOCTYPE html>
<html lang="en" ><head><meta charset="utf-8" /><title>Vimeo API - OAuth and Upload Example | Script Tutorials</title><link href="css/main.css" rel="stylesheet" type="text/css" /></head><body><header><h2>Vimeo API - OAuth and Upload Example</h2><a href="https://www.script-tutorials.com/vimeo-api-oauth-and-upload-example/" class="stuts">Back to original tutorial on <span>Script Tutorials</span></a></header><img src="vim.png" class="vim" alt="vimeo" /><?php if ($_SESSION['vimeo_state'] == 'start'): ?><center><h1>Step 1. OAuth</h1><h2>Click the link to go to Vimeo to authorize your account.</h2><p><a href="<?= $authorize_link ?>"><?php echo $authorize_link ?></a></p></center><?php endif ?><?php if ($bUploadCase && $sUploadResult == ''): ?><center><h1>Step 2. Video info</h1><h2>Now we should send video file, title and description to Vimeo</h2></center><form enctype="multipart/form-data" action="index.php" method="post"><input type="hidden" name="action" value="upload" /><label for="file">Please choose a file:</label><input name="file" type="file" /><label for="title">Title:</label><input name="title" type="text" /><label for="description">Description:</label><input name="description" type="text" /><input type="submit" value="Upload" /></form><?php endif ?><?php if ($sUploadResult): ?><center><h1>Step 4. Final</h1><h2><?php echo $sUploadResult ?></h2></center><?php endif ?><br /><center><h2>(<a href="?action=clear">Click here to start over</a>)</h2></center></body>
</html>

In the beginning – we should attach ‘vimeo.php’ library, you can download this library here. This is a very convenient library to work with Vimeo. All the logic functionality are more easy than in case of Youtube. In case of Vimeo we should: (a) send request to vimeo website in order to obtain oauth_access_token and oauth_access_token_secret, (b) then we should send to vimeo file itself (via POST), and also title and description of our file (as text). In the result – our file should be uploaded. All this code is commented very well, so I hope that you don’t have difficulties with understanding.

首先,我们应该附加“ vimeo.php”库,您可以在此处下载该库。 这是使用Vimeo的非常方便的库。 与Youtube相比,所有逻辑功能都更加简单。 如果是Vimeo,我们应该:(a)发送请求到vimeo网站以获得oauth_access_token和oauth_access_token_secret,(b)然后我们应该发送文件到vimeo文件本身(通过POST),以及文件的标题和描述(作为文本) )。 结果–我们的文件应该上传了。 所有这些代码的注释都很好,因此希望您在理解上没有困难。

步骤2. CSS (Step 2. CSS)

Now we can stylize our page elements:

现在我们可以样式化页面元素:

css / main.css (css/main.css)


.vim {display: block;margin: 40px auto;
}
form {background-color: #ddd;display: block;margin: 20px auto;padding: 15px;width: 400px;
}
label {display: block;margin-bottom: 5px;
}
input, select {border-style: groove;font-size: 16px;height: 25px;margin-bottom: 10px;width: 400px;/*css3 border radius*/-moz-border-radius: 5px;-ms-border-radius: 5px;-o-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;/* CSS3 Box sizing property */-moz-box-sizing: border-box;-webkit-box-sizing: border-box;-o-box-sizing: border-box;box-sizing: border-box;
}
input[type=submit], input[type=file]{cursor: pointer;font-weight: bold;height: 35px;padding: 5px;
}

.vim {display: block;margin: 40px auto;
}
form {background-color: #ddd;display: block;margin: 20px auto;padding: 15px;width: 400px;
}
label {display: block;margin-bottom: 5px;
}
input, select {border-style: groove;font-size: 16px;height: 25px;margin-bottom: 10px;width: 400px;/*css3 border radius*/-moz-border-radius: 5px;-ms-border-radius: 5px;-o-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;/* CSS3 Box sizing property */-moz-box-sizing: border-box;-webkit-box-sizing: border-box;-o-box-sizing: border-box;box-sizing: border-box;
}
input[type=submit], input[type=file]{cursor: pointer;font-weight: bold;height: 35px;padding: 5px;
}

现场演示

结论 (Conclusion)

Today we have made our next really useful tutorial. Sure that this information will be useful for your own projects. Good luck in your work!

今天,我们做了下一个真正有用的教程。 确保此信息对您自己的项目有用。 祝您工作顺利!

翻译自: https://www.script-tutorials.com/vimeo-api-oauth-and-upload-example/

vimeo 镜像

vimeo 镜像_Vimeo API – OAuth和上传示例相关推荐

  1. vimeo 镜像_Vimeo的首席应用程序开发人员Kevin Sheurs访谈

    vimeo 镜像 Vimeo is quickly becoming one of my favorite websites. You can find videos on just about an ...

  2. vue 移动端头像裁剪_vue头像上传裁剪组件_一个漂亮的Vue组件,用于图像裁剪和上传...

    vue头像上传裁剪组件 vue-image-crop-upload (vue-image-crop-upload) A beautiful vue component for image crop a ...

  3. linux怎样自动检查link文件_自动共享和上传文件到兼容的托管站点 | Linux 中国

    Anypaste 将会根据你想上传的文件的类型来自动挑选合适的托管站点.简单地说,照片将被上传到图像托管站点,视频被传到视频站点,代码被传到 pastebin. -- Sk(作者) 前阵子我们写了一个 ...

  4. java如何处理csv文件上传_java处理csv文件上传示例

    前言:示例只是做了一个最最基础的上传csv的示例,如果要引用到代码中去,还需要根据自己的业务自行添加一些逻辑处理. ReadCsvUtil工具类 package com.hanfengyeqiao.g ...

  5. jQuery AJAX 网页无刷新上传示例

    新年礼,提供简单.易套用的 jQuery AJAX 上传示例及代码下载.后台对文件的上传及检查,以 C#/.NET Handler 处理 (可视需要改写成 Java 或 PHP). 有时做一个网站项目 ...

  6. jsp servlet示例_Servlet和JSP中的文件上传示例

    jsp servlet示例 使用Servlet和JSP将文件上传到服务器是Java Web应用程序中的常见任务. 在对Servlet或JSP进行编码以处理文件上传请求之前,您需要了解一点有关HTML和 ...

  7. Servlet和JSP中的文件上传示例

    使用Servlet和JSP将文件上传到服务器是Java Web应用程序中的常见任务. 在对Servlet或JSP进行编码以处理文件上传请求之前,您需要了解一点有关HTML和HTTP协议中文件上传支持的 ...

  8. java上传csv错误信息_java处理csv文件上传示例详解

    前言:示例只是做了一个最最基础的上传csv的示例,如果要引用到代码中去,还需要根据自己的业务自行添加一些逻辑处理. ReadCsvUtil工具类 package com.hanfengyeqiao.g ...

  9. java上传csv文件上传_java处理csv文件上传示例详解

    前言:示例只是做了一个最最基础的上传csv的示例,如果要引用到代码中去,还需要根据自己的业务自行添加一些逻辑处理. readcsvutil工具类 package com.hanfengyeqiao.g ...

最新文章

  1. linux如何进入单用户模式
  2. 职场疑问:如何进行技术面试
  3. Secure-CRT使用技巧
  4. 富文本编辑器 java_Java开发之富文本编辑器TinyMCE
  5. OpenCV学习笔记(一)——OpenCV3.1.0+VS2015开发环境配置
  6. Win10远程连接自己的电脑提示“登陆没有成功”的解决方案
  7. shell监控usr目录
  8. 是以微型计算机为中心 配以相应的外围设备,______是以微型计算机为中心,配以相应的外围设备、电源和辅助电路,以及指挥微型计算机工作的系统软件而构成的。...
  9. 转 JS操作JSON总结
  10. matplotlib 2.2.4 has requirement python-dateutil=2.1, but you'll have python-dateutil 1.5
  11. Origin画并列柱状图
  12. 进阶篇:2)DFMA方法的运用
  13. 复制html代码怎么粘贴快捷键,电脑复制粘贴快捷键,教您电脑怎么用键盘复制粘贴...
  14. 简单演示程序序列号的破解
  15. uniapp提示用户开启定位,跳转到开启定位页面
  16. 为何用户体验无法被设计,如何为用户体验设计
  17. word中如何选中已经衬于文字下的形状
  18. 带负荷测试要求二次最小电流_互感器二次负荷在线测试方法与流程
  19. 数电课设汽车尾灯控制电路
  20. 花几个小时做一个看股票的摸鱼神器

热门文章

  1. 判断一个日期是一年中的第几天
  2. 厦门工程技术人员职称申报操作笔记 01 继续教育学时
  3. 学习计算机审计的原因,计算机审计学习心得体会
  4. CSS基础-05-颜色取值、标签居中(了解即可)、综合案例-新闻内容
  5. 如何才能打造优秀高效的项目团队?
  6. kafka节点的服役和退役
  7. win7下载python3.7.4_Python for windows 下载
  8. 亚马逊程序员:我曾拼命逃离996
  9. MMGG吃螃蟹 | Solana上去中心化结构性产品-Exotic
  10. 正点原子FPGA开发指南——数码管动态显示