Esempio n. 1
0
<?php

require_once '../libs/BaiduPCS.class.php';
//请根据实际情况更新$access_token与$appName参数
$access_token = '3.839af46f54db6ed60797847d2febbca0.2592000.1359262544.754976761-248414';
//应用目录名
$appName = '测试应用';
//应用根目录
$root_dir = '/apps' . '/' . $appName . '/';
//文件路径
$path = $root_dir . '';
$pcs = new BaiduPCS($access_token);
$result = $pcs->getMeta($path);
echo $result;
Esempio n. 2
0
        header('Content-Type: application/ogg');
    } elseif ($file_ext == 'wma') {
        header('Content-Type: audio/x-ms-wma');
    } elseif ($file_ext == 'wav') {
        header('Content-Type: audio/x-wav');
    } elseif ($file_ext == 'mid' || $file_ext == 'midi') {
        header('Content-Type: audio/midi');
    } else {
        header('Content-Type: application/octet-stream');
    }
    header('Content-Length: ' . strlen($result));
    header('Content-Disposition: inline; filename="' . $file_name . '"');
    header('Accept-Ranges: bytes');
    header('X-Pad: avoid browser bug');
} elseif (in_array($file_ext, array('asf', 'avi', 'flv', 'mkv', 'mov', 'mp4', 'wmv', '3gp', '3g2', 'mpeg', 'rm', 'rmvb', 'qt'))) {
    $meta = $BaiduPCS->getMeta($path);
    $meta = json_decode($meta, true);
    if (isset($meta['error_msg'])) {
        header("Content-Type: text/html; charset=utf8");
        echo $meta['error_msg'];
        exit;
    }
    $meta = $meta['list'][0];
    $meta = $meta['block_list'];
    $meta = json_decode($meta);
    $meta = $meta[0];
    header("Location: video-player.php?path=" . urlencode($path) . "&md5=" . $meta);
    exit;
} else {
    $result = $BaiduPCS->download($path);
    $meta = json_decode($result, true);