saveas.php 851B

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