No Description

get_bucketList.php 734B

123456789101112131415161718192021222324252627
  1. <?php
  2. require_once __DIR__ . '/../autoload.php';
  3. use Qiniu\Auth;
  4. use Qiniu\Config;
  5. use Qiniu\Storage\BucketManager;
  6. // 控制台获取密钥:https://portal.qiniu.com/user/key
  7. $accessKey = getenv('QINIU_ACCESS_KEY');
  8. $secretKey = getenv('QINIU_SECRET_KEY');
  9. $auth = new Auth($accessKey, $secretKey);
  10. $config = new Config();
  11. $bucketManager = new BucketManager($auth, $config);
  12. // 列举空间,返回 bucket 列表
  13. // 存储区域参考文档:https://developer.qiniu.com/kodo/manual/1671/region-endpoint
  14. $region = 'z1'; // 华东:z0,华北:z1,华南:z2,北美:na0,东南亚:as0
  15. list($ret, $err) = $bucketManager->listbuckets($region);
  16. if ($err != null) {
  17. var_dump($err);
  18. } else {
  19. var_dump($ret);
  20. }