-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.php
executable file
·49 lines (43 loc) · 1.62 KB
/
sample.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
echo "hello";
/*****YoukuUpload SDK*****/
header('Content-type: text/html; charset=utf-8');
include("include/YoukuUploader.class.php");
$client_id = "543b42c7e397a413"; // Youku OpenAPI client_id
$client_secret = "b6621cef41d6dce6151c751e21b3c408"; //Youku OpenAPI client_secret
/*
**The way with username and password applys to the partner level clients!
**Others may use access_token to upload the video file.
**In addition, refresh_token is to refresh expired access_token.
**If it is null, the access_token would not be refreshed.
**You may refresh it by yourself.
**Like "http://open.youku.com/docs/api/uploads/client/english" for reference.
*/
$params['access_token'] = "";
$params['refresh_token'] = "";
$params['username'] = "[email protected]"; //Youku username or email
$params['password'] = md5("AAbb3344"); //Youku password
set_time_limit(0);
ini_set('memory_limit', '128M');
$youkuUploader = new YoukuUploader($client_id, $client_secret);
$file_name = "/home/roger/test1.mwv"; //video file
try {
$file_md5 = @md5_file($file_name);
if (!$file_md5) {
throw new Exception("Could not open the file!\n");
}
}catch (Exception $e) {
echo "(File: ".$e->getFile().", line ".$e->getLine()."): ".$e->getMessage();
return;
}
$file_size = filesize($file_name);
$uploadInfo = array(
"title" => "", //video title
"tags" => "", //tags, split by space
"file_name" => $file_name, //video file name
"file_md5" => $file_md5, //video file's md5sum
"file_size" => $file_size //video file size
);
$progress = true; //if true,show the uploading progress
$youkuUploader->upload($progress, $params,$uploadInfo);
?>