|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
require "../autoload.php"; |
|
4
|
|
|
|
|
5
|
|
|
$cli = new \Qiniu\Http\Client(); |
|
6
|
|
|
|
|
7
|
|
|
$url = 'https://acc.qbox.me/oauth2/token'; |
|
8
|
|
|
$param = array( |
|
9
|
|
|
'grant_type' => 'password', |
|
10
|
|
|
'username' => "[email protected]", |
|
11
|
|
|
'password' => urlencode(''), |
|
12
|
|
|
); |
|
13
|
|
|
$param = http_build_query($param); |
|
14
|
|
|
$headers = array( |
|
15
|
|
|
'Content-Type' => 'application/x-www-form-urlencoded' |
|
16
|
|
|
); |
|
17
|
|
|
|
|
18
|
|
|
//https://developer.qiniu.com/af/manual/1600/get-account-management-credentials-and-secret-lock |
|
19
|
|
|
$resp = $cli::post($url, $param, $headers); |
|
20
|
|
|
|
|
21
|
|
|
$res = json_decode($resp->body, true); |
|
22
|
|
|
|
|
23
|
|
|
echo '----------------------------token:\n'; |
|
24
|
|
|
var_dump($res); |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
//$res2 = createChildAccount("[email protected]", 'xxxxxtest', $res['access_token']); |
|
28
|
|
|
//echo '----------------------------create child account:\n'; |
|
29
|
|
|
//var_dump($res2); |
|
30
|
|
|
|
|
31
|
|
|
//https://developer.qiniu.com/af/manual/1534/create-a-account-user-create-child |
|
32
|
|
|
function createChildAccount($email, $pwd, $aToken) { |
|
33
|
|
|
$headers = array( |
|
34
|
|
|
'Authorization' => 'Bearer ' . $aToken |
|
35
|
|
|
); |
|
36
|
|
|
$param = 'email=' . $email . '&password=' . $pwd; |
|
37
|
|
|
|
|
38
|
|
|
$cli = new \Qiniu\Http\Client(); |
|
39
|
|
|
$resp = $cli::post('https://acc.qbox.me/user/create_child', $param, $headers); |
|
40
|
|
|
|
|
41
|
|
|
return $resp->body; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
$res3 = getAkSk("1380483031", $res['access_token']); |
|
46
|
|
|
echo '----------------------------get ak sk:\n'; |
|
47
|
|
|
var_dump($res3); |
|
|
|
|
|
|
48
|
|
|
|
|
49
|
|
|
function getAkSk($uid, $aToken) { |
|
50
|
|
|
$headers = array( |
|
51
|
|
|
'Authorization' => 'Bearer ' . $aToken |
|
52
|
|
|
); |
|
53
|
|
|
$param = ''; |
|
54
|
|
|
|
|
55
|
|
|
$cli = new \Qiniu\Http\Client(); |
|
56
|
|
|
$resp = $cli::post('https://acc.qbox.me/user/child_key?uid=' . $uid, $param, $headers); |
|
57
|
|
|
|
|
58
|
|
|
return $resp->body; |
|
59
|
|
|
} |
|
60
|
|
|
|