From 7fb24a25d904645368cdbf7963f37bae1fbfafba Mon Sep 17 00:00:00 2001 From: Chaim Date: Tue, 5 May 2020 15:42:20 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E5=A2=9E=E5=8A=A0=20=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 6 ++- .../douyin => exception}/DouYinException.php | 2 +- src/service/WeMini/NewTmplService.php | 41 +++++++++++++++++++ src/service/douyin/WatermarkService.php | 7 ++++ 4 files changed, 54 insertions(+), 2 deletions(-) rename src/{service/douyin => exception}/DouYinException.php (96%) create mode 100644 src/service/WeMini/NewTmplService.php diff --git a/composer.json b/composer.json index 9955d13..1afa2cb 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,11 @@ "topthink/framework": "^6.0.0", "topthink/think-orm": "^2.0", "liguangchun/ip": "^1.1", - "ext-bcmath": "*" + "ext-bcmath": "*", + "aliyuncs/oss-sdk-php": "^2.3", + "obs/esdk-obs-php": "^3.19", + "baidubce/bce-sdk-php": "^0.8.22", + "qcloud/cos-sdk-v5": "^2.0" }, "autoload": { "files": [ diff --git a/src/service/douyin/DouYinException.php b/src/exception/DouYinException.php similarity index 96% rename from src/service/douyin/DouYinException.php rename to src/exception/DouYinException.php index 5fb7351..c22d393 100644 --- a/src/service/douyin/DouYinException.php +++ b/src/exception/DouYinException.php @@ -14,7 +14,7 @@ // | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library // +---------------------------------------------------------------------- -namespace DtApp\ThinkLibrary\service\douyin; +namespace DtApp\ThinkLibrary\exception; use Exception; diff --git a/src/service/WeMini/NewTmplService.php b/src/service/WeMini/NewTmplService.php new file mode 100644 index 0000000..b5570fd --- /dev/null +++ b/src/service/WeMini/NewTmplService.php @@ -0,0 +1,41 @@ +http(str_replace('ACCESS_TOKEN', $access_token, $url), '', true); + } +} diff --git a/src/service/douyin/WatermarkService.php b/src/service/douyin/WatermarkService.php index 4862f50..2424c0b 100644 --- a/src/service/douyin/WatermarkService.php +++ b/src/service/douyin/WatermarkService.php @@ -16,6 +16,7 @@ namespace DtApp\ThinkLibrary\service\douyin; +use DtApp\ThinkLibrary\exception\DouYinException; use DtApp\ThinkLibrary\facade\Pregs; use DtApp\ThinkLibrary\Service; use stdClass; @@ -238,11 +239,14 @@ class WatermarkService extends Service * 正则匹配 mid * @param $content * @return mixed + * @throws DouYinException */ private function getItemId($content) { preg_match('/"(?<=itemId:\s\")\d+"/', $content, $matches); + if (!isset($matches[0])) throw new DouYinException('视频不存在'); preg_match("~\"(.*?)\"~", $matches[0], $matches2); + if (!isset($matches2[1])) throw new DouYinException('视频不存在'); return $matches2[1]; } @@ -250,12 +254,15 @@ class WatermarkService extends Service * 正则匹配 dytk * @param $content * @return mixed + * @throws DouYinException */ private function getDyTk($content) { preg_match("~dytk(.*?)}~", $content, $matches); + if (!isset($matches[1])) throw new DouYinException('视频不存在'); $Dytk = $matches[1]; preg_match("~\"(.*?)\"~", $Dytk, $matches2); + if (!isset($matches2[1])) throw new DouYinException('视频不存在'); return $matches2[1]; }