Home  >  Article  >  Backend Development  >  各位大牛谁知道怎么用php 生成token 七牛云存储

各位大牛谁知道怎么用php 生成token 七牛云存储

WBOY
WBOYOriginal
2016-06-06 20:24:191830browse

我需要用php生成 七牛规则中的token,不知道该怎么生成,请问具体方法。

回复内容:

我需要用php生成 七牛规则中的token,不知道该怎么生成,请问具体方法。

<code>$data['scope']='你的bucket';
$data['deadline']=time()+3600;
$encoded=urlsafe_base64_encode(json_encode($data));
$signature=hash_hmac('sha1',$encoded,'KEY',true);
$encode_signed = urlsafe_base64_encode($signature);
$UploadToken='AK:'.$encode_signed.':'.$encoded;
  
echo $UploadToken;</code>

SDK有现成的,
$token = $auth->uploadToken($bucket);

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn