1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace App\Services\Vendor\Tencent;
- use App\Services\Service;
- use TencentCloud\Cms\V20190321\CmsClient;
- use TencentCloud\Cms\V20190321\Models\AudioModerationRequest;
- use TencentCloud\Cms\V20190321\Models\ImageModerationRequest;
- use TencentCloud\Cms\V20190321\Models\TextModerationRequest;
- use TencentCloud\Common\Credential;
- use TencentCloud\Common\Profile\ClientProfile;
- use TencentCloud\Common\Profile\HttpProfile;
- class SecureService extends Service
- {
- // EvilFlag 0:正常 1:可疑
- // EvilType 100:正常
- // 20001:政治
- // 20002:色情
- // 20006:涉毒违法
- // 20007:谩骂
- // 20105:广告引流
- // 24001:暴恐
- // 21000:综合
- private $client;
- public function __construct()
- {
- $cred = new Credential('AKIDMXdeS40dLsBdw4QxahdNWyEJ9PbjkceL', 'oGbw73lcMzSkvvj07bsxnPn0ykJjyysa');
- $httpProfile = new HttpProfile();
- $httpProfile->setEndpoint("cms.tencentcloudapi.com");
- $clientProfile = new ClientProfile();
- $clientProfile->setHttpProfile($httpProfile);
- $this->client = new CmsClient($cred, "ap-guangzhou", $clientProfile);
- }
- public function text(string $text)
- {
- $req = new TextModerationRequest();
- $req->fromJsonString(json_encode(
- ['Content' => base64_encode($text)]
- ));
- $resp = $this->client->TextModeration($req);
- dump($resp->toJsonString());
- }
- public function image(string $url)
- {
- $req = new ImageModerationRequest();
- $req->fromJsonString(json_encode([
- 'FileUrl' => $url,
- ]));
- $resp = $this->client->ImageModeration($req);
- dump($resp->toJsonString());
- }
- public function voice(string $url)
- {
- $req = new AudioModerationRequest();
- $req->fromJsonString(json_encode([
- 'FileUrl' => $url,
- ]));
- $resp = $this->client->AudioModeration($req);
- dump($resp->toJsonString());
- }
- }
|