Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
数据应用
ThinkLibrary
提交
a66fb6ec
T
ThinkLibrary
项目概览
数据应用
/
ThinkLibrary
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
代码片段
项目成员
Pages
T
ThinkLibrary
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a66fb6ec
编写于
6月 08, 2020
作者:
李光春
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
- 优化代码
- 增加七牛云云存储 - 增加又拍云云存储
上级
47146575
变更
22
隐藏空白更改
内联
并排
Showing
22 changed file
with
221 addition
and
246 deletion
+221
-246
src/cache/Mysql.php
src/cache/Mysql.php
+1
-2
src/config.php
src/config.php
+20
-0
src/helper/Requests.php
src/helper/Requests.php
+1
-1
src/helper/Xmls.php
src/helper/Xmls.php
+3
-7
src/service/CaptchaService.php
src/service/CaptchaService.php
+0
-177
src/service/StorageService.php
src/service/StorageService.php
+1
-2
src/service/aliyun/OssService.php
src/service/aliyun/OssService.php
+2
-4
src/service/baidu/BosService.php
src/service/baidu/BosService.php
+2
-4
src/service/bt/ApiService.php
src/service/bt/ApiService.php
+2
-4
src/service/crypt/AesService.php
src/service/crypt/AesService.php
+1
-2
src/service/curl/BtService.php
src/service/curl/BtService.php
+3
-6
src/service/curl/HttpService.php
src/service/curl/HttpService.php
+3
-6
src/service/douyin/WatermarkService.php
src/service/douyin/WatermarkService.php
+3
-10
src/service/huaweicloud/ObsService.php
src/service/huaweicloud/ObsService.php
+2
-4
src/service/jd/UnionService.php
src/service/jd/UnionService.php
+2
-4
src/service/jdcloud/VientianeService.php
src/service/jdcloud/VientianeService.php
+1
-3
src/service/pinduoduo/JinBaoService.php
src/service/pinduoduo/JinBaoService.php
+1
-2
src/service/qiniu/KodoService.php
src/service/qiniu/KodoService.php
+87
-0
src/service/taobao/TbkService.php
src/service/taobao/TbkService.php
+1
-2
src/service/tencent/CosService.php
src/service/tencent/CosService.php
+2
-4
src/service/upyun/UssService.php
src/service/upyun/UssService.php
+82
-0
src/service/wechat/MiniService.php
src/service/wechat/MiniService.php
+1
-2
未找到文件。
src/cache/Mysql.php
浏览文件 @
a66fb6ec
...
...
@@ -31,8 +31,7 @@ use think\facade\Db;
class
Mysql
{
private
$table
=
"think_cache"
;
private
$cache_name
;
private
$cache_expire
=
0
;
private
$cache_name
,
$cache_expire
=
0
;
/**
* 名称
...
...
src/config.php
浏览文件 @
a66fb6ec
...
...
@@ -143,4 +143,24 @@ return [
'storage'
=>
[
'path'
=>
''
],
// 又拍云
'upyun'
=>
[
// 又拍云存储
'uss'
=>
[
'service_name'
=>
''
,
'operator_name'
=>
''
,
'operator_password'
=>
''
,
'url'
=>
''
,
]
],
// 七牛云
'qiniu'
=>
[
// 云存储
'kodo'
=>
[
'access_key'
=>
''
,
'secret_key'
=>
''
,
'bucket'
=>
''
,
'url'
=>
''
,
]
],
];
src/helper/Requests.php
浏览文件 @
a66fb6ec
...
...
@@ -32,7 +32,7 @@ class Requests
*/
public
function
isEmpty
(
array
$data
,
array
$arr
):
array
{
foreach
(
$arr
as
$k
=>
$v
)
if
(
empty
(
isset
(
$data
[
"
$v
"
])
?
$data
[
"
$v
"
]
:
''
))
return
''
;
foreach
(
$arr
as
$k
=>
$v
)
if
(
empty
(
isset
(
$data
[
"
$v
"
])
?
$data
[
"
$v
"
]
:
''
))
return
[]
;
return
$data
;
}
...
...
src/helper/Xmls.php
浏览文件 @
a66fb6ec
...
...
@@ -37,13 +37,9 @@ class Xmls
if
(
!
is_array
(
$values
)
||
count
(
$values
)
<=
0
)
throw
new
Exception
(
'数组数据异常!'
);
$xml
=
"<xml>"
;
foreach
(
$values
as
$key
=>
$val
)
{
if
(
is_array
(
$val
))
{
$xml
.
=
"<"
.
$key
.
">"
.
$this
->
toXml
(
$val
)
.
"</"
.
$key
.
">"
;
}
else
if
(
is_numeric
(
$val
))
{
$xml
.
=
"<"
.
$key
.
">"
.
$val
.
"</"
.
$key
.
">"
;
}
else
{
$xml
.
=
"<"
.
$key
.
"><![CDATA["
.
$val
.
"]]></"
.
$key
.
">"
;
}
if
(
is_array
(
$val
))
$xml
.
=
"<"
.
$key
.
">"
.
$this
->
toXml
(
$val
)
.
"</"
.
$key
.
">"
;
else
if
(
is_numeric
(
$val
))
$xml
.
=
"<"
.
$key
.
">"
.
$val
.
"</"
.
$key
.
">"
;
else
$xml
.
=
"<"
.
$key
.
"><![CDATA["
.
$val
.
"]]></"
.
$key
.
">"
;
}
$xml
.
=
"</xml>"
;
return
$xml
;
...
...
src/service/CaptchaService.php
已删除
100644 → 0
浏览文件 @
47146575
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 :https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 :https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace
DtApp\ThinkLibrary\service
;
use
DtApp\ThinkLibrary\Service
;
/**
* 图形验证码服务
* Class CaptchaService
* @package DtApp\ThinkLibrary\service
*/
class
CaptchaService
extends
Service
{
private
$code
;
// 验证码
private
$uniqid
;
// 唯一序号
private
$charset
=
'ABCDEFGHKMNPRSTUVWXYZ23456789'
;
// 随机因子
private
$codelen
=
4
;
// 验证码长度
private
$width
=
130
;
// 宽度
private
$height
=
50
;
// 高度
private
$img
;
// 图形资源句柄
private
$font
;
// 指定的字体
private
$fontsize
=
20
;
// 指定字体大小
private
$fontcolor
;
// 指定字体颜色
/**
* 服务初始化
* @param array $config
* @return CaptchaService
*/
protected
function
initialize
(
$config
=
[])
{
// 动态配置属性
foreach
(
$config
as
$k
=>
$v
)
if
(
isset
(
$this
->
$k
))
$this
->
$k
=
$v
;
// 生成验证码序号
$this
->
uniqid
=
uniqid
(
'captcha'
)
.
mt_rand
(
1000
,
9999
);
// 生成验证码字符串
$length
=
strlen
(
$this
->
charset
)
-
1
;
for
(
$i
=
0
;
$i
<
$this
->
codelen
;
$i
++
)
{
$this
->
code
.
=
$this
->
charset
[
mt_rand
(
0
,
$length
)];
}
// 设置字体文件路径
$this
->
font
=
__DIR__
.
'/bin/font.ttf'
;
// 缓存验证码字符串
$this
->
app
->
cache
->
set
(
$this
->
uniqid
,
$this
->
code
,
360
);
// 返回当前对象
return
$this
;
}
/**
* 动态切换配置
* @param array $config
* @return $this
*/
public
function
config
(
$config
=
[])
{
return
$this
->
initialize
(
$config
);
}
/**
* 获取验证码值
* @return string
*/
public
function
getCode
()
{
return
$this
->
code
;
}
/**
* 获取图片内容
* @return string
*/
public
function
getData
()
{
return
"data:image/png;base64,
{
$this
->
createImage
()
}
"
;
}
/**
* 获取验证码编号
* @return string
*/
public
function
getUniqid
()
{
return
$this
->
uniqid
;
}
/**
* 获取验证码数据
* @return array
*/
public
function
getAttrs
()
{
return
[
'code'
=>
$this
->
getCode
(),
'data'
=>
$this
->
getData
(),
'uniqid'
=>
$this
->
getUniqid
(),
];
}
/**
* 检查验证码是否正确
* @param string $code 需要验证的值
* @param string $uniqid 验证码编号
* @return boolean
*/
public
function
check
(
$code
,
$uniqid
=
null
)
{
$_uni
=
is_string
(
$uniqid
)
?
$uniqid
:
input
(
'uniqid'
,
'-'
);
$_val
=
$this
->
app
->
cache
->
get
(
$_uni
,
''
);
if
(
is_string
(
$_val
)
&&
strtolower
(
$_val
)
===
strtolower
(
$code
))
{
$this
->
app
->
cache
->
delete
(
$_uni
);
return
true
;
}
else
{
return
false
;
}
}
/**
* 输出图形验证码
* @return string
*/
public
function
__toString
()
{
return
$this
->
getData
();
}
/**
* 创建验证码图片
* @return string
*/
private
function
createImage
()
{
// 生成背景
$this
->
img
=
imagecreatetruecolor
(
$this
->
width
,
$this
->
height
);
$color
=
imagecolorallocate
(
$this
->
img
,
mt_rand
(
220
,
255
),
mt_rand
(
220
,
255
),
mt_rand
(
220
,
255
));
imagefilledrectangle
(
$this
->
img
,
0
,
$this
->
height
,
$this
->
width
,
0
,
$color
);
// 生成线条
for
(
$i
=
0
;
$i
<
6
;
$i
++
)
{
$color
=
imagecolorallocate
(
$this
->
img
,
mt_rand
(
0
,
50
),
mt_rand
(
0
,
50
),
mt_rand
(
0
,
50
));
imageline
(
$this
->
img
,
mt_rand
(
0
,
$this
->
width
),
mt_rand
(
0
,
$this
->
height
),
mt_rand
(
0
,
$this
->
width
),
mt_rand
(
0
,
$this
->
height
),
$color
);
}
// 生成雪花
for
(
$i
=
0
;
$i
<
100
;
$i
++
)
{
$color
=
imagecolorallocate
(
$this
->
img
,
mt_rand
(
200
,
255
),
mt_rand
(
200
,
255
),
mt_rand
(
200
,
255
));
imagestring
(
$this
->
img
,
mt_rand
(
1
,
5
),
mt_rand
(
0
,
$this
->
width
),
mt_rand
(
0
,
$this
->
height
),
'*'
,
$color
);
}
// 生成文字
$_x
=
$this
->
width
/
$this
->
codelen
;
for
(
$i
=
0
;
$i
<
$this
->
codelen
;
$i
++
)
{
$this
->
fontcolor
=
imagecolorallocate
(
$this
->
img
,
mt_rand
(
0
,
156
),
mt_rand
(
0
,
156
),
mt_rand
(
0
,
156
));
if
(
function_exists
(
'imagettftext'
))
{
imagettftext
(
$this
->
img
,
$this
->
fontsize
,
mt_rand
(
-
30
,
30
),
$_x
*
$i
+
mt_rand
(
1
,
5
),
$this
->
height
/
1.4
,
$this
->
fontcolor
,
$this
->
font
,
$this
->
code
[
$i
]);
}
else
{
imagestring
(
$this
->
img
,
15
,
$_x
*
$i
+
mt_rand
(
10
,
15
),
mt_rand
(
10
,
30
),
$this
->
code
[
$i
],
$this
->
fontcolor
);
}
}
ob_start
();
imagepng
(
$this
->
img
);
$data
=
ob_get_contents
();
ob_end_clean
();
imagedestroy
(
$this
->
img
);
return
base64_encode
(
$data
);
}
}
src/service/StorageService.php
浏览文件 @
a66fb6ec
...
...
@@ -25,8 +25,7 @@ use DtApp\ThinkLibrary\Service;
*/
class
StorageService
extends
Service
{
private
$path
=
''
;
private
$remotely
=
''
;
private
$path
=
''
,
$remotely
=
''
;
/**
* 文件夹
...
...
src/service/aliyun/OssService.php
浏览文件 @
a66fb6ec
...
...
@@ -22,15 +22,13 @@ use OSS\OssClient;
/**
* 阿里云对象存储
* https://www.aliyun.com/product/oss
* Class OssService
* @package DtApp\ThinkLibrary\service\aliyun
*/
class
OssService
extends
Service
{
private
$accessKeyId
;
private
$accessKeySecret
;
private
$endpoint
;
private
$bucket
;
private
$accessKeyId
,
$accessKeySecret
,
$endpoint
,
$bucket
;
public
function
accessKeyId
(
string
$accessKeyId
)
{
...
...
src/service/baidu/BosService.php
浏览文件 @
a66fb6ec
...
...
@@ -22,15 +22,13 @@ use Exception;
/**
* 百度云对象存储
* https://cloud.baidu.com/product/bos.html
* Class BosService
* @package DtApp\ThinkLibrary\service\baidu
*/
class
BosService
extends
Service
{
private
$accessKeyId
;
private
$secretAccessKey
;
private
$endpoint
;
private
$bucket
;
private
$accessKeyId
,
$secretAccessKey
,
$endpoint
,
$bucket
;
public
function
accessKeyId
(
string
$accessKeyId
)
{
...
...
src/service/bt/ApiService.php
浏览文件 @
a66fb6ec
...
...
@@ -22,6 +22,7 @@ use DtApp\ThinkLibrary\service\curl\BtService;
/**
* 宝塔Api
* https://www.bt.cn/
* Class ApiService
* @package DtApp\ThinkLibrary\service\bt
*/
...
...
@@ -32,10 +33,7 @@ class ApiService extends Service
private
$limit
=
15
;
private
$order
=
'id desc'
;
private
$where
=
[];
private
$contents
;
private
$backtrack
;
private
$key
;
private
$panel
;
private
$contents
,
$backtrack
,
$key
,
$panel
;
public
function
key
(
string
$key
)
{
...
...
src/service/crypt/AesService.php
浏览文件 @
a66fb6ec
...
...
@@ -20,8 +20,7 @@ use DtApp\ThinkLibrary\Service;
class
AesService
extends
Service
{
private
$key
;
private
$iv
;
private
$key
,
$iv
;
public
function
key
(
$str
)
{
...
...
src/service/curl/BtService.php
浏览文件 @
a66fb6ec
...
...
@@ -21,17 +21,14 @@ use think\exception\HttpException;
/**
* 宝塔网络请求接口
* https://www.bt.cn/
* Class BtService
* @package DtApp\ThinkLibrary\service\curl
*/
class
BtService
extends
Service
{
private
$url
;
private
$key
;
private
$url
,
$key
,
$panel
,
$output
,
$cookie
;
private
$data
=
[];
private
$panel
;
private
$output
;
private
$cookie
;
private
$timeout
=
60
;
/**
...
...
@@ -107,7 +104,7 @@ class BtService extends Service
*/
public
function
toArray
(
bool
$is
=
true
)
{
if
(
empty
(
$this
->
cookie
))
throw
new
HttpException
(
404
,
'请检查cookie内容'
);
if
(
empty
(
$this
->
cookie
))
throw
new
HttpException
(
404
,
'请检查cookie内容'
);
if
(
!
extension_loaded
(
"curl"
))
throw
new
HttpException
(
404
,
'请开启curl模块!'
);
$this
->
http
();
if
(
empty
(
$is
))
return
$this
->
output
;
...
...
src/service/curl/HttpService.php
浏览文件 @
a66fb6ec
...
...
@@ -26,10 +26,7 @@ use think\exception\HttpException;
*/
class
HttpService
extends
Service
{
private
$url
;
private
$data
;
private
$cert
;
private
$output
;
private
$url
,
$data
,
$cert
,
$output
;
private
$timeout
=
60
;
private
$method
=
'GET'
;
private
$headers
=
'application/json;charset=utf-8'
;
...
...
@@ -52,7 +49,7 @@ class HttpService extends Service
*/
public
function
data
(
$str
)
{
if
(
is_array
(
$str
))
$this
->
data
=
json_encode
(
$str
,
JSON_UNESCAPED_UNICODE
);
if
(
is_array
(
$str
))
$this
->
data
=
json_encode
(
$str
,
JSON_UNESCAPED_UNICODE
);
else
$this
->
data
=
$str
;
return
$this
;
}
...
...
@@ -151,7 +148,7 @@ class HttpService extends Service
$this
->
httpXml
();
}
else
if
(
$this
->
method
===
'FILE'
)
{
$this
->
httpFile
();
}
else
throw
new
HttpException
(
404
,
'请求方式异常'
);
}
else
throw
new
HttpException
(
404
,
'请求方式异常'
);
if
(
empty
(
$is
))
return
$this
->
output
;
if
(
is_array
(
$this
->
output
))
return
$this
->
output
;
return
json_decode
(
$this
->
output
,
true
);
...
...
src/service/douyin/WatermarkService.php
浏览文件 @
a66fb6ec
...
...
@@ -34,14 +34,7 @@ use stdClass;
*/
class
WatermarkService
extends
Service
{
private
$url
;
private
$api_url
;
private
$itemId
;
private
$dytk
;
private
$contents
;
private
$backtrack
;
private
$storage
;
private
$storagePath
;
private
$url
,
$apiUrl
,
$itemId
,
$dytk
,
$contents
,
$backtrack
,
$storage
,
$storagePath
;
/**
* 配置网址
...
...
@@ -184,8 +177,8 @@ class WatermarkService extends Service
*/
public
function
getApi
()
{
$this
->
api
_u
rl
=
"https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=
{
$this
->
itemId
}
&dytk=
{
$this
->
dytk
}
"
;
$this
->
contents
=
$this
->
getContents
(
$this
->
api
_u
rl
);
$this
->
api
U
rl
=
"https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=
{
$this
->
itemId
}
&dytk=
{
$this
->
dytk
}
"
;
$this
->
contents
=
$this
->
getContents
(
$this
->
api
U
rl
);
$this
->
backtrack
=
$this
->
contents
;
return
$this
;
}
...
...
src/service/huaweicloud/ObsService.php
浏览文件 @
a66fb6ec
...
...
@@ -21,15 +21,13 @@ use Obs\ObsClient;
/**
* 华为云对象存储
* https://www.huaweicloud.com/product/obs.html
* Class ObsService
* @package DtApp\ThinkLibrary\service\huaweicloud
*/
class
ObsService
extends
Service
{
private
$key
;
private
$secret
;
private
$endpoint
;
private
$bucket
;
private
$key
,
$secret
,
$endpoint
,
$bucket
;
public
function
key
(
string
$key
)
{
...
...
src/service/jd/UnionService.php
浏览文件 @
a66fb6ec
...
...
@@ -38,8 +38,7 @@ class UnionService extends Service
* API接口名称
* @var
*/
private
$method
=
''
;
private
$response
=
''
;
private
$method
=
''
,
$response
=
''
;
/**
* 联盟分配给应用的appkey
...
...
@@ -87,8 +86,7 @@ class UnionService extends Service
* 需要发送的的参数
* @var
*/
private
$param
;
private
$params
;
private
$param
,
$params
;
/**
* 联盟分配给应用的appkey
...
...
src/service/jdcloud/VientianeService.php
浏览文件 @
a66fb6ec
...
...
@@ -29,9 +29,7 @@ class VientianeService extends Service
{
private
$url
=
"https://way.jd.com/"
;
private
$param
;
private
$app_key
;
private
$param
,
$app_key
;
/**
* 您申请的appkey
...
...
src/service/pinduoduo/JinBaoService.php
浏览文件 @
a66fb6ec
...
...
@@ -37,8 +37,7 @@ class JinBaoService extends Service
* API接口名称
* @var string
*/
private
$type
=
''
;
private
$response
=
''
;
private
$type
=
''
,
$response
=
''
;
/**
* 开放平台分配的clientId
...
...
src/service/qiniu/KodoService.php
0 → 100644
浏览文件 @
a66fb6ec
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 :https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 :https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace
DtApp\ThinkLibrary\service\qiniu
;
use
DtApp\ThinkLibrary\Service
;
use
Exception
;
use
Qiniu\Auth
;
use
Qiniu\Storage\UploadManager
;
/**
* 七牛云对象存储
* https://www.qiniu.com/products/kodo
* Class KodoService
* @package DtApp\ThinkLibrary\service\qiniu
*/
class
KodoService
extends
Service
{
private
$accessKey
,
$secretKey
,
$bucket
;
public
function
accessKey
(
string
$accessKey
)
{
$this
->
accessKey
=
$accessKey
;
return
$this
;
}
public
function
secretKey
(
string
$secretKey
)
{
$this
->
secretKey
=
$secretKey
;
return
$this
;
}
public
function
bucket
(
string
$bucket
)
{
$this
->
bucket
=
$bucket
;
return
$this
;
}
/**
* 获取配置信息
* @return $this
*/
private
function
getConfig
()
{
$this
->
accessKey
=
$this
->
app
->
config
->
get
(
'dtapp.qiniu.kodo.access_key'
);
$this
->
secretKey
=
$this
->
app
->
config
->
get
(
'dtapp.qiniu.kodo.secret_key'
);
$this
->
bucket
=
$this
->
app
->
config
->
get
(
'dtapp.qiniu.kodo.bucket'
);
return
$this
;
}
/**
* 上传文件
* @param $object
* @param $filePath
* @return bool
* @throws Exception
*/
public
function
upload
(
string
$object
,
string
$filePath
)
{
if
(
empty
(
$this
->
accessKey
))
$this
->
getConfig
();
if
(
empty
(
$this
->
secretKey
))
$this
->
getConfig
();
if
(
empty
(
$this
->
bucket
))
$this
->
getConfig
();
// 初始化签权对象
$auth
=
new
Auth
(
$this
->
accessKey
,
$this
->
secretKey
);
// 生成上传Token
$token
=
$auth
->
uploadToken
(
$this
->
bucket
);
// 构建 UploadManager 对象
$uploadMgr
=
new
UploadManager
();
// 调用 UploadManager 的 putFile 方法进行文件的上传。
list
(
$ret
,
$err
)
=
$uploadMgr
->
putFile
(
$token
,
$object
,
$filePath
);
if
(
$err
!==
null
)
return
false
;
else
return
$this
->
app
->
config
->
get
(
'dtapp.qiniu.kodo.url'
)
.
$object
;
}
}
src/service/taobao/TbkService.php
浏览文件 @
a66fb6ec
...
...
@@ -50,8 +50,7 @@ class TbkService extends Service
* API接口名称
* @var string
*/
private
$method
=
''
;
private
$response
=
''
;
private
$method
=
''
,
$response
=
''
;
/**
* 签名的摘要算法
...
...
src/service/tencent/CosService.php
浏览文件 @
a66fb6ec
...
...
@@ -22,15 +22,13 @@ use Qcloud\Cos\Client;
/**
* 腾讯云对象存储
* https://cloud.tencent.com/product/cos
* Class CosService
* @package DtApp\ThinkLibrary\service\tencent
*/
class
CosService
extends
Service
{
private
$secretId
;
private
$secretKey
;
private
$region
;
private
$bucket
;
private
$secretId
,
$secretKey
,
$region
,
$bucket
;
public
function
secretId
(
string
$secretId
)
{
...
...
src/service/upyun/UssService.php
0 → 100644
浏览文件 @
a66fb6ec
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 :https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 :https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace
DtApp\ThinkLibrary\service\upyun
;
use
DtApp\ThinkLibrary\Service
;
use
Exception
;
use
Upyun\Config
;
use
Upyun\Upyun
;
/**
* 又拍云存储
* https://www.upyun.com/products/file-storage
* Class UssService
* @package DtApp\ThinkLibrary\service\upyun
*/
class
UssService
extends
Service
{
private
$serviceName
,
$operatorName
,
$operatorPassword
;
public
function
serviceName
(
string
$serviceName
)
{
$this
->
serviceName
=
$serviceName
;
return
$this
;
}
public
function
operatorName
(
string
$operatorName
)
{
$this
->
operatorName
=
$operatorName
;
return
$this
;
}
public
function
operatorPassword
(
string
$operatorPassword
)
{
$this
->
operatorPassword
=
$operatorPassword
;
return
$this
;
}
/**
* 获取配置信息
* @return $this
*/
private
function
getConfig
()
{
$this
->
serviceName
=
$this
->
app
->
config
->
get
(
'dtapp.upyun.uss.service_name'
);
$this
->
operatorName
=
$this
->
app
->
config
->
get
(
'dtapp.upyun.uss.operator_name'
);
$this
->
operatorPassword
=
$this
->
app
->
config
->
get
(
'dtapp.upyun.uss.operator_password'
);
return
$this
;
}
/**
* 上传文件
* @param string $object
* @param string $filePath
* @return bool
* @throws Exception
*/
public
function
upload
(
string
$object
,
string
$filePath
)
{
if
(
empty
(
$this
->
serviceName
))
$this
->
getConfig
();
if
(
empty
(
$this
->
operatorName
))
$this
->
getConfig
();
if
(
empty
(
$this
->
operatorPassword
))
$this
->
getConfig
();
$serviceConfig
=
new
Config
(
$this
->
serviceName
,
$this
->
operatorName
,
$this
->
operatorPassword
);
$client
=
new
Upyun
(
$serviceConfig
);
$file
=
fopen
(
$filePath
,
'r'
);
$client
->
write
(
$object
,
$file
);
return
$this
->
app
->
config
->
get
(
'dtapp.upyun.uss.url'
)
.
$object
;
}
}
src/service/wechat/MiniService.php
浏览文件 @
a66fb6ec
...
...
@@ -32,8 +32,7 @@ class MiniService extends Service
{
private
$api_url
=
"https://api.weixin.qq.com/"
;
private
$app_id
;
private
$app_secret
;
private
$app_id
,
$app_secret
;
private
$grant_type
=
"client_credential"
;
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录