Bez popisu

censor_image.php 912B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. require_once __DIR__ . '/../autoload.php';
  3. use Qiniu\Auth;
  4. use Qiniu\Config;
  5. use Qiniu\Storage\ArgusManager;
  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. $argusManager = new ArgusManager($auth, $config);
  12. // 图片内容审核
  13. // 参考文档:https://developer.qiniu.com/censor/api/5588/image-censor
  14. $body = '{
  15. "data":{
  16. "uri":"https://www-static.qbox.me/_next/static/media/pic01.c8b5db2cc5fcb6fc4e6349c9e37c8e6b.png"
  17. },
  18. "params":{
  19. "scenes":[
  20. "pulp",
  21. "terror",
  22. "politician",
  23. "ads"
  24. ]
  25. }
  26. }';
  27. list($ret, $err) = $argusManager->censorImage($body);
  28. echo "\n====> Result is: \n";
  29. if ($err !== null) {
  30. var_dump($err);
  31. } else {
  32. var_dump($ret);
  33. }