123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- require_once __DIR__ . '/vendor/autoload.php';
- $bucket = 'examplebucket-1250000000';
- $secretKey = 'SECRETKEY';
- $secretId = 'SECRETID';
- $region = "ap-beijing";
- $sts = new QCloud\COSSTS\Sts();
- $config = array(
- 'url' => 'https://sts.tencentcloudapi.com/',
- 'domain' => 'sts.tencentcloudapi.com',
- 'proxy' => '',
- 'secretId' => $secretId,
- 'secretKey' => $secretKey,
- 'bucket' => $bucket,
- 'region' => $region,
- 'durationSeconds' => 1800*10,
- 'allowPrefix' => array('/*'),
- 'allowCiSource' => true,
- 'allowActions' => array (
- 'name/cos:*',
- 'name/ci:*',
-
- ),
- );
- try {
-
- $tempKeys = $sts->getTempKeys($config);
- print_r($tempKeys);
- } catch (Exception $e) {
- echo $e;
- }
- $tmpSecretId = 'secretId';
- $tmpSecretKey = 'secretKey';
- $token = 'token';
- $tokenClient = new Qcloud\Cos\Client(
- array(
- 'region' => $region,
- 'scheme' => 'https',
- 'credentials'=> array(
- 'secretId' => $tmpSecretId ,
- 'secretKey' => $tmpSecretKey,
- 'token' => $token,
- )
- )
- );
- try {
- $content = '敏感词';
- $result = $tokenClient->detectText(array(
- 'Bucket' => 'examplebucket-1250000000',
- 'Input' => array(
- 'Content' => base64_encode($content),
- ),
- ));
-
- print_r($result);
- } catch (\Exception $e) {
-
- echo($e);
- }
|