Last active
February 26, 2022 08:28
-
-
Save 330132662/7f14dfe7b052341552da83b3fd1033a0 to your computer and use it in GitHub Desktop.
又拍云token生成测试-这是错误实例,不能用他们的演示代码。。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sign($key, $secret, $method, $uri, $date, $policy = null, $md5 = null) | |
{ | |
$elems = array(); | |
foreach (array($method, $uri, $date, $policy, $md5) as $v) { | |
if ($v) { | |
$elems[] = $v; | |
} | |
} | |
$value = implode('&', $elems); | |
$sign = base64_encode(hash_hmac('sha1', $value, $secret, true)); | |
return 'UPYUN ' . $key . ':' . $sign; | |
} | |
function index3() | |
{ | |
$key = 'aaeb09fc85c7e3d4fb5c874efc48393e.jpg'; | |
// $key = 'upyun'; | |
$secret = '***'; | |
$uri = '/androidtest/'; | |
$method = 'GET'; | |
$date = gmdate('D, d M Y H:i:s \G\M\T', time() + 3600 * 24);//*8是当前时间 *24是想把过期时间往后拖一下 | |
// echo gmdate('Y-m-d H:i:s', time() + 3600 * 8); | |
$md = md5($secret); | |
echo $date . "\n"; | |
echo $md . "\n"; | |
// 上传,处理,内容识别有存储 | |
echo $this->sign($key, md5($secret), $method, $uri, $date) . "\n"; | |
// 内容识别无存储,容器云 | |
// echo $this->sign($key, $secret, $method, $uri, $date); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment