Skip to content

Commit 463e543

Browse files
committed
Nothing
0 parents  commit 463e543

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1480
-0
lines changed

.gitignore

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Mac OS X Finder and whatnot
2+
.DS_Store
3+
4+
# XCode (and ancestors) per-user config (very noisy, and not relevant)
5+
*.mode1
6+
*.mode1v3
7+
*.mode2v3
8+
*.perspective
9+
*.perspectivev3
10+
*.pbxuser
11+
xcuserdata
12+
*.xcworkspace
13+
14+
# Generated files
15+
VersionX-revision.h
16+
17+
18+
# build products
19+
build/
20+
*.[oa]
21+
22+
# Other source repository archive directories (protects when importing)
23+
.hg
24+
.svn
25+
CVS
26+
SexToys/www/.DS_Store
27+
28+
SexToys/.DS_Store
29+
30+
leveldb/.DS_Store
31+
32+
leveldb/doc/.DS_Store
33+
34+
leveldb/helpers/.DS_Store
35+
36+
leveldb/port/.DS_Store
37+
38+
SexToys/SVWebViewController.bundle/.DS_Store
39+
40+
leveldb/include/.DS_Store
41+
42+
*. DS_Store
43+
*.yaml
44+
*.svg
45+
46+
Doc*

Examples/accountInfo.php

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
include_once('config.php');
4+
session_start();
5+
6+
7+
//实例化 \Vdisk\OAuth2
8+
$oauth2 = new \Vdisk\OAuth2(VDISK_CLIENT_ID, VDISK_CLIENT_SECRET);
9+
10+
//判断是否登录, 并且给$oauth2->accessToken负值
11+
if (isset($_SESSION['token']) &&
12+
isset($_SESSION['token']->access_token) &&
13+
$token = $oauth2->getTokenFromObject($_SESSION['token'])) {
14+
15+
$client = new \Vdisk\Client($oauth2, 'basic');
16+
$client->setDebug(true);
17+
18+
try {
19+
20+
// Attempt to retrieve the account information
21+
$response = $client->accountInfo();
22+
$accountInfo = $response['body'];
23+
// Dump the output
24+
echo "<pre>";
25+
print_r($accountInfo);
26+
echo "</pre>";
27+
28+
} catch (\Vdisk\Exception $e) {
29+
30+
echo "<pre>";
31+
echo get_class($e) . ' ' . '#' . $e->getCode() . ': ' . $e->getMessage();
32+
echo "</pre>";
33+
}
34+
35+
} else {
36+
37+
echo "您还没有登录, <a href='index.php'>去登录</a>";
38+
}

Examples/callback.php

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
/**
4+
* PHP SDK for Sina Vdisk (using OAuth2)
5+
* @author Bruce Chen <[email protected]>
6+
*/
7+
8+
header('Content-Type: text/html; charset=UTF-8');
9+
10+
include_once('config.php');
11+
session_start();
12+
13+
$oauth2 = new \Vdisk\OAuth2(VDISK_CLIENT_ID, VDISK_CLIENT_SECRET);
14+
$oauth2->debug = false;
15+
16+
if (isset($_REQUEST['code'])) {
17+
18+
$keys = array();
19+
$keys['code'] = $_REQUEST['code'];
20+
$keys['redirect_uri'] = VDISK_CALLBACK_URL;
21+
22+
try {
23+
24+
$token = $oauth2->getAccessToken('code', $keys);
25+
$_SESSION['token'] = $token;
26+
header('Location: index.php');
27+
28+
} catch (Exception $e) {
29+
30+
echo "<pre>";
31+
print_r($e->getMessage());
32+
echo "</pre>";
33+
echo "<a href='index.php'>返回</a>";
34+
}
35+
}
36+
37+
/*
38+
39+
if ($token) {
40+
41+
$_SESSION['token'] = $token;
42+
43+
$client = new \Vdisk\Client($oauth2, 'basic');
44+
45+
try {
46+
47+
//$d = $client->accountInfo();
48+
$d = $client->metaData('/', null, 10000, false, false, false);
49+
print_r($d);
50+
51+
} catch (\Vdisk\Exception $e) {
52+
53+
echo "<pre>";
54+
echo '(' . get_class($e) . ') #' . $e->getCode() . ': [' . $e->getMessage() . ']';
55+
echo "</pre>";
56+
echo "<a href='index.php'>返回</a>";
57+
}
58+
}
59+
60+
*/

Examples/config.php

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
include_once('../Vdisk/Vdisk.php');
4+
5+
define('VDISK_CLIENT_ID', 'xxxxxxxxxx');
6+
define('VDISK_CLIENT_SECRET', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
7+
define('VDISK_CALLBACK_URL', 'http://xxxxxxxxxxxxxxxxxxxxxxxxxx');

Examples/images/folder.png

617 Bytes

Examples/images/folder_app.png

1.08 KB

Examples/images/folder_camera.png

1023 Bytes
1023 Bytes

Examples/images/folder_photos.png

1.63 KB

Examples/images/folder_public.png

1.25 KB

Examples/images/folder_user.png

929 Bytes

Examples/images/keynote.png

931 Bytes

Examples/images/numbers.png

813 Bytes

Examples/images/page_white.png

461 Bytes
1.06 KB
855 Bytes

Examples/images/page_white_c.png

845 Bytes

Examples/images/page_white_code.png

565 Bytes
614 Bytes
828 Bytes

Examples/images/page_white_csharp.png

851 Bytes

Examples/images/page_white_cup.png

834 Bytes

Examples/images/page_white_dvd.png

2.19 KB

Examples/images/page_white_excel.png

762 Bytes

Examples/images/page_white_film.png

759 Bytes

Examples/images/page_white_flash.png

991 Bytes

Examples/images/page_white_gear.png

1000 Bytes

Examples/images/page_white_h.png

809 Bytes

Examples/images/page_white_js.png

840 Bytes

Examples/images/page_white_paint.png

1000 Bytes

Examples/images/page_white_php.png

849 Bytes
990 Bytes
801 Bytes

Examples/images/page_white_ruby.png

818 Bytes

Examples/images/page_white_sound.png

928 Bytes

Examples/images/page_white_text.png

696 Bytes

Examples/images/page_white_tux.png

1.03 KB

Examples/images/page_white_vector.png

1.01 KB
861 Bytes

Examples/images/page_white_word.png

782 Bytes

Examples/images/pages.png

696 Bytes

Examples/index.php

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
/**
4+
* PHP SDK for Sina Vdisk (using OAuth2)
5+
* @author Bruce Chen <[email protected]>
6+
*/
7+
8+
/*
9+
10+
phpdoc run -f ./Vdisk/Vdisk.php -t ./Doc --sourcecode --title "新浪微盘SDK For PHP" --hidden --validate
11+
12+
*/
13+
14+
include_once('config.php');
15+
session_start();
16+
17+
if (isset($_GET['logout']) && $_GET['logout'] == 1) { //退出登录, 清除SESSION
18+
19+
session_destroy();
20+
header('Location: index.php');
21+
}
22+
23+
24+
$is_login = false;
25+
26+
//实例化 \Vdisk\OAuth2
27+
$oauth2 = new \Vdisk\OAuth2(VDISK_CLIENT_ID, VDISK_CLIENT_SECRET);
28+
29+
//判断是否登录, 并且给$oauth2->accessToken负值
30+
if (isset($_SESSION['token']) &&
31+
isset($_SESSION['token']->access_token) &&
32+
$token = $oauth2->getTokenFromObject($_SESSION['token'])) {
33+
34+
$is_login = true;
35+
}
36+
37+
38+
39+
?>
40+
41+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
42+
<html>
43+
<head>
44+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
45+
<meta http-equiv="Content-Style-Type" content="text/css">
46+
<title>新浪微盘SDK实例</title>
47+
<meta name="Generator" content="Cocoa HTML Writer">
48+
<meta name="CocoaVersion" content="1187.34">
49+
<style type="text/css"></style>
50+
</head>
51+
<body>
52+
53+
<?php if ($is_login) { ?>
54+
55+
<div><a href="index.php?logout=1&<?=time();?>">退出登录</a></div>
56+
<div>
57+
<ul>
58+
59+
<li><a href="accountInfo.php">获得用户信息</a></li>
60+
<li><a href="metaData.php">获得文件/目录信息</a></li>
61+
62+
</ul>
63+
</div>
64+
65+
<?php
66+
67+
echo "<pre>";
68+
print_r($token);
69+
echo "</pre>";
70+
71+
} else { ?>
72+
73+
<a href="<?=$oauth2->getAuthorizeURL(VDISK_CALLBACK_URL, 'code', time(), 'mobile');?>">点击授权并登录微盘</a>
74+
75+
<?php } ?>
76+
77+
</body>
78+
</html>

Examples/metaData.php

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?php
2+
3+
include_once('config.php');
4+
session_start();
5+
6+
7+
//实例化 \Vdisk\OAuth2
8+
$oauth2 = new \Vdisk\OAuth2(VDISK_CLIENT_ID, VDISK_CLIENT_SECRET);
9+
10+
//判断是否登录, 并且给$oauth2->accessToken负值
11+
if (isset($_SESSION['token']) &&
12+
isset($_SESSION['token']->access_token) &&
13+
$token = $oauth2->getTokenFromObject($_SESSION['token'])) {
14+
15+
$client = new \Vdisk\Client($oauth2, 'basic');
16+
//$client->setDebug(true);
17+
18+
try {
19+
20+
if (isset($_GET['path'])) {
21+
22+
$path = $_GET['path'];
23+
24+
} else {
25+
26+
$path = '/';
27+
}
28+
29+
// Attempt to retrieve the account information
30+
$response = $client->metaData($path);
31+
$metaData = $response['body'];
32+
33+
} catch (\Vdisk\Exception $e) {
34+
35+
echo "<pre>";
36+
echo get_class($e) . ' ' . '#' . $e->getCode() . ': ' . $e->getMessage();
37+
echo "</pre>";
38+
}
39+
40+
} else {
41+
42+
echo "您还没有登录, <a href='index.php'>去登录</a>";
43+
}
44+
45+
?>
46+
47+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
48+
<html>
49+
<head>
50+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
51+
<meta http-equiv="Content-Style-Type" content="text/css">
52+
<title>新浪微盘SDK实例</title>
53+
<meta name="Generator" content="Cocoa HTML Writer">
54+
<meta name="CocoaVersion" content="1187.34">
55+
<style type="text/css"></style>
56+
</head>
57+
<body>
58+
59+
<?php if ($metaData) { ?>
60+
61+
<div><h2>Index Of: <?=$metaData->path?></h2></div>
62+
63+
<?php
64+
65+
if (isset($metaData->contents)) {
66+
67+
?>
68+
69+
<div>
70+
<ul>
71+
72+
<?php
73+
74+
foreach ($metaData->contents as $value) {
75+
?>
76+
77+
<li>
78+
<img src="images/<?=$value->icon;?>.png" /><a href="metaData.php?path=<?=urlencode($value->path);?>"><?=end(explode('/', $value->path));?></a>
79+
&nbsp;&nbsp;&nbsp;
80+
<?php
81+
82+
if (!$value->is_dir) {
83+
84+
echo $value->size;
85+
}
86+
?>
87+
&nbsp;&nbsp;&nbsp;
88+
<?=date('Y-m-d H:i:s', strtotime($value->modified));?>
89+
</li>
90+
91+
<?php
92+
}
93+
?>
94+
95+
</ul>
96+
</div>
97+
98+
<?php } } ?>
99+
100+
</body>
101+
</html>
102+

0 commit comments

Comments
 (0)