Ejemplo n.º 1
0
    var_dump($_SESSION);
} elseif (isset($_SESSION['kb_refresh_token']) && $_SESSION['kb_refresh_token']) {
    $kbauth = new kbAuthClass();
    $refreshtoken = $kbauth->refreshNewAccesstoken($_SESSION['kb_refresh_token']);
    $_SESSION['kb_refresh_token'] = $refreshtoken['refresh_token'];
    $_SESSION['kb_access_token'] = $refreshtoken['access_token'];
    var_dump($_SESSION);
    echo '<br>';
} else {
    $kbauth = new kbAuthClass();
    if (isset($_GET['code']) && $_GET['code']) {
        $token = $kbauth->getTokenByAuthcode($_GET['code'], $redirect_url);
        $_SESSION['kb_refresh_token'] = $token['refresh_token'];
        $_SESSION['kb_access_token'] = $token['access_token'];
    } else {
        header('location: ' . $kbauth->getAuthorizeURL($redirect_url));
    }
}
$apiinstance = new KanboxApiClass();
//获取账户信息,包括酷盘空间大小及使用情况
var_dump($apiinstance->call_function($_SESSION['kb_access_token'], 'account_info'));
//获取由path指定的路径下,文件列表信息,path类型为string,为空时,默认访问根目录
//var_dump($apiinstance->call_function($_SESSION['kb_access_token'],'files_list',array('path'=>'')));
//获取由path指定的文件,对应的下载地址,path类型为string
//var_dump($apiinstance->call_function($_SESSION['kb_access_token'],'get_down_url',array('path'=>'/欢迎使用酷盘.pdf')));
//上传文件,path类型为string,destination_path为将此文件上传到酷盘后对应的路径及文件名,destination_path类型为string
//var_dump($apiinstance->call_function($_SESSION['kb_access_token'],'upload_file',array('path'=>'http://192.168.5.43:81/phpsdk/ssd.txt','destination_path'=>'/ssd.txt')));
//删除由path指定的路径下的文件或文件夹,path类型为string
//var_dump($apiinstance->call_function($_SESSION['kb_access_token'],'delete_file',array('path'=>'/ddd.pdf')));
//移动由path指定的路径下的文件或文件夹,到destination_path指定的路径,path及destination_path的类型均为string,可用于重命名,路径不变,替换文件名即可
//var_dump($apiinstance->call_function($_SESSION['kb_access_token'],'move_file',array('path'=>'/ccc.pdf','destination_path'=>'/ddd.pdf')));