|
1 | 1 | <?php |
2 | | - require_once __DIR__ . '/../autoload.php'; |
3 | | - |
4 | | - use Qiniu\Auth; |
5 | | - use Qiniu\Processing\PersistentFop; |
| 2 | +require_once __DIR__ . '/../autoload.php'; |
6 | 3 |
|
7 | | - // 后台来获取AK, SK |
8 | | - $accessKey = 'Access_Key'; |
9 | | - $secretKey = 'Secret_Key'; |
| 4 | +use Qiniu\Auth; |
| 5 | +use Qiniu\Processing\PersistentFop; |
10 | 6 |
|
11 | | - //生成EncodedEntryURI的值 |
12 | | - $entry='<bucket>:<Key>';//<Key>为生成缩略图的文件名 |
13 | | - //生成的值 |
14 | | - $encodedEntryURI=\Qiniu\base64_urlSafeEncode($entry); |
| 7 | +// 后台来获取AK, SK |
| 8 | +$accessKey = 'Access_Key'; |
| 9 | +$secretKey = 'Secret_Key'; |
15 | 10 |
|
16 | | - //使用SecretKey对新的下载URL进行HMAC1-SHA1签名 |
17 | | - $newurl = "78re52.com1.z0.glb.clouddn.com/resource/Ship.jpg?imageView2/2/w/200/h/200|saveas/".$encodedEntryURI; |
| 11 | +//生成EncodedEntryURI的值 |
| 12 | +$entry='<bucket>:<Key>';//<Key>为生成缩略图的文件名 |
| 13 | +//生成的值 |
| 14 | +$encodedEntryURI=\Qiniu\base64_urlSafeEncode($entry); |
18 | 15 |
|
19 | | - $sign = hash_hmac("sha1", $newurl, $secretKey, true); |
| 16 | +//使用SecretKey对新的下载URL进行HMAC1-SHA1签名 |
| 17 | +$newurl = "78re52.com1.z0.glb.clouddn.com/resource/Ship.jpg?imageView2/2/w/200/h/200|saveas/".$encodedEntryURI; |
20 | 18 |
|
21 | | - //对签名进行URL安全的Base64编码 |
22 | | - $encodedSign = \Qiniu\base64_urlSafeEncode($sign); |
23 | | - //最终得到的完整下载URL |
24 | | - $finalURL = "http://".$newurl."/sign/".$accessKey.":".$encodedSign; |
| 19 | +$sign = hash_hmac("sha1", $newurl, $secretKey, true); |
25 | 20 |
|
26 | | - $callbackBody = file_get_contents("$finalURL"); |
| 21 | +//对签名进行URL安全的Base64编码 |
| 22 | +$encodedSign = \Qiniu\base64_urlSafeEncode($sign); |
| 23 | +//最终得到的完整下载URL |
| 24 | +$finalURL = "http://".$newurl."/sign/".$accessKey.":".$encodedSign; |
27 | 25 |
|
28 | | - echo $callbackBody; |
| 26 | +$callbackBody = file_get_contents("$finalURL"); |
| 27 | + |
| 28 | +echo $callbackBody; |
0 commit comments